ModuleNotFoundError, trying to use binance.websockets

Viewed 8074

Hi I thought this would be pretty straightforwards but I can't figure it out.

It can't find binance.websockets for whatever reason even though it can find binance.client which should be part of the same package?

import config
import os

from binance.client import Client
from twisted.internet import reactor
from binance.websockets import BinanceSocketManager

Running this import code gives this error

Traceback (most recent call last):
  File "/home/lucho/Documents/cryptoAPIs/binance/importconfig.py", line 6, in <module>
    from binance.websockets import BinanceSocketManager
ModuleNotFoundError: No module named 'binance.websockets

To get the library I installed with pip3

pip3 install python-binance

pip3 install binance-api

3 Answers

The BinanceSocketManager is no longer in the websockets file. Change your import to this:

from binance.streams import BinanceSocketManager

This will fix the issue

use this " pip install python-binance==0.7.9 "

If you look into the breaking changes on version 1.0.1 they mention they changes Websockets, so that is probably what you are hitting.

I would just reinstall the latest version "pip install python-binance" and use the up to date examples on their repo: https://github.com/sammchardy/python-binance

Related