BetaRavener / upy-websocket-server

Micropython (ESP8266) websocket server implementation.
MIT License
80 stars 24 forks source link

ImportError: cannot import name websocket on ESP32 #1

Closed rdagger closed 6 years ago

rdagger commented 7 years ago

When I run the websocket.py I get the following error:

Traceback (most recent call last): File "", line 1, in File "websocket.py", line 1, in File "ws_connection.py", line 2, in ImportError: cannot import name websocket

Looks like websocket.py imports from ws_connection.py which then tries to import websocket from websocket.py which doesn't contain a class called websocket. Not sure if it matters, but I'm using an ESP32 with latest firmware.

BetaRavener commented 7 years ago

Hi, thanks for reporting it. I look into it, but bear in mind that ESP32 is new device and maybe not all of the micropython functionality that runs on ESP8266 may be available already. Websockets may not be implemented yet for ESP32 (although if the WebREPL is working, they should be). EDIT: First thing, try to rename websocket.py that you downloaded from here to something else. It shouldn't matter how it's called. I just noticed that I named the filed same as library from where it should import the class.

rdagger commented 7 years ago

I did try renaming and it didn't help. WebREPL is not implemented for the ESP32 as far as I know and there is no module named websocket on the latest firmware. Thanks.

goatchurchprime commented 6 years ago

In particular, your main module is called "websocket.py" which is pretty confusing if there is an outside library also called websocket.

I mean it's inconsistent if the line at the top of websocket.py is: from ws_connection import ClientClosedError and it's supposed to import from ws_connection.py

but the line at the top of ws_connection.py is from websocket import websocket and it's NOT supposed to import from websocket.py

ws_connection

BetaRavener commented 6 years ago

Sorry, this was already changed but forgot to push. It should be clear now which is which.

BetaRavener commented 6 years ago

Should be resolved.