I have this python script that sends a WebSocket message to my python server. But it keeps throwing errors. I have seen these errors before, but I can't seem to fix it. I use the 2.7.x
version.
#!/usr/bin/python
import websocket
import sys
val = sys.argv[1]
ws = websocket.create_connection("ws://ipaddress:9001")
ws.send(val)
ws.close()
The Error
Traceback (most recent call last):
File "./test.py", line 5, in <module>
ws = websocket.create_connection("ws://ipaddress:9001")
AttributeError: 'module' object has no attribute 'create_connection'
you've installed the wrong library (websocket
)
try installing websocket-client
$ pip install websocket-client
and then your code must work just fine