njouanin / hbmqtt

MQTT client/broker using Python asynchronous I/O
MIT License
800 stars 188 forks source link

Issue: ModuleNotFoundError: No module named 'websockets.protocol' #239

Open ivanrulik opened 3 years ago

ivanrulik commented 3 years ago

I had used previously hbmqtt but now I'm getting this error always:

from hbmqtt.broker import Broker File "/Users/ivanrulik/env/work1/lib/python3.8/site-packages/hbmqtt/broker.py", line 15, in from hbmqtt.session import Session File "/Users/ivanrulik/env/work1/lib/python3.8/site-packages/hbmqtt/session.py", line 8, in from hbmqtt.mqtt.publish import PublishPacket File "/Users/ivanrulik/env/work1/lib/python3.8/site-packages/hbmqtt/mqtt/init.py", line 5, in from hbmqtt.mqtt.packet import ( File "/Users/ivanrulik/env/work1/lib/python3.8/site-packages/hbmqtt/mqtt/packet.py", line 8, in from hbmqtt.adapters import ReaderAdapter, WriterAdapter File "/Users/ivanrulik/env/work1/lib/python3.8/site-packages/hbmqtt/adapters.py", line 6, in from websockets.protocol import WebSocketCommonProtocol ModuleNotFoundError: No module named 'websockets.protocol'

Any advice or help to fix it will be greatly appreciated

FlorianLudwig commented 3 years ago

@ivanrulik can you post your config?

ivanrulik commented 3 years ago

@FlorianLudwig sure thing, I’m using Mac OS Big Sur with python 3.8.2. I made this post also because I tried to use the library in windows 10 and got the same issue. I’m not really sure if maybe having the code inside a OneDrive synced folder could be the reason of the issue.

HerrMuellerluedenscheid commented 3 years ago

websocket released v0.9

FlorianLudwig commented 3 years ago

@ivanrulik could you retry with the current master branch from amqtt?

doanthienthuan commented 3 years ago

i have the same error ? have anyone fixed it

FlorianLudwig commented 3 years ago

I just released amqtt version 0.10.0-alpha.4 which is compatible with websocktets versions 9.x

mweinelt commented 3 years ago

https://websockets.readthedocs.io/en/stable/changelog.html#id5

The client, server, protocol, and auth modules were moved from the websockets package to websockets.legacy sub-package, as part of an upcoming refactoring. Despite the name, they’re still fully supported. The refactoring should be a transparent upgrade for most uses when it’s available. The legacy implementation will be preserved according to the backwards-compatibility policy.

sina-rostami commented 3 years ago

pip install "websockets==8.1"

worked for me.