pythonwebsocketbinance

ModuleNotFoundError, trying to use binance.websockets


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


Solution

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

    from binance.streams import BinanceSocketManager
    

    For python-binance 1.0.27v try:

    from binance import BinanceSocketManager