Lucho
Lucho

Reputation: 99

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

Upvotes: 6

Views: 13421

Answers (3)

Archangel
Archangel

Reputation: 302

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

Upvotes: 15

Gyancarlo Garcia
Gyancarlo Garcia

Reputation: 21

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

Upvotes: 2

Piyush
Piyush

Reputation: 61

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

Upvotes: 6

Related Questions