--I want to import websocket --I want to do websocket.create_connection ()
sumple_ws.py
from websocket import create_connection
↓
Traceback (most recent call last):
File "sumple_ws.py", line 10, in <module>
from websocket import create_connection
ImportError: cannot import name 'create_connection' from 'websocket' (unknown location)
:thinking:
It seems that the packages to be used on the server side and the client side are different
Incorrect in this case
$ pip install websocket
This is the correct answer
$ pip install websocket-client
However, when importing, both are websocket
Please read the readable code
Yes perfect
$ pip install websocket-client
$ pip uninstall websocket
$ pip freeze | grep websocket
websocket-client==0.57.0
Is reproduced
sumple_ws.py
from websocket import create_connection
Traceback (most recent call last):
File "sumple_ws.py", line 10, in <module>
from websocket import create_connection
ImportError: cannot import name 'create_connection' from 'websocket' (unknown location)
Check in interactive mode
>>> import websocket
>>> dir(websocket)
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
:thinking: :thinking: :thinking:
$ pip uninstall websocket-client
$ pip install websocket-client
Interactive mode
```python
>>> import websocket
>>> dir(websocket)
['ABNF', 'DEFAULT_SOCKET_OPTION', 'STATUS_ABNORMAL_CLOSED', 'STATUS_BAD_GATEWAY', 'STATUS_GOING_AWAY', 'STATUS_INVALID_EXTENSION', 'STATUS_INVALID_PAYLOAD', 'STATUS_MESSAGE_TOO_BIG', 'STATUS_NORMAL', 'STATUS_POLICY_VIOLATION', 'STATUS_PROTOCOL_ERROR', 'STATUS_STATUS_NOT_AVAILABLE', 'STATUS_TLS_HANDSHAKE_ERROR', 'STATUS_UNEXPECTED_CONDITION', 'STATUS_UNSUPPORTED_DATA_TYPE', 'WebSocket', 'WebSocketAddressException', 'WebSocketApp', 'WebSocketBadStatusException', 'WebSocketConnectionClosedException', 'WebSocketException', 'WebSocketPayloadException', 'WebSocketProtocolException', 'WebSocketProxyException', 'WebSocketTimeoutException', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_abnf', '_app', '_cookiejar', '_core', '_exceptions', '_handshake', '_http', '_logging', '_socket', '_ssl_compat', '_url', '_utils', 'continuous_frame', 'create_connection', 'debug', 'dump', 'enableTrace', 'error', 'frame_buffer', 'getdefaulttimeout', 'isEnabledForDebug', 'isEnabledForError', 'isEnabledForTrace', 'recv', 'recv_line', 'send', 'setdefaulttimeout', 'sock_opt', 'trace', 'warning']
This time perfect
###Factor It seems that there was something wrong with the timing of installation and uninstallation
This is
$ pip install websocket-client
$ pip uninstall websocket
I should have been in this order
$ pip uninstall websocket
$ pip install websocket-client