I'm a fairly new to Python and I am trying to enter the following code:
from websocket import create_connection as cc
import json, time
I want to look at BTC and LTC stocks in a live feed type-fashion but I keep getting this error:
ModuleNotFoundError: No module named 'websocket'
I've been looking around and it seems that a common solution is:
pip install websocket
that just didn't connect with me. Most sites say install this and just have the above code but I have no idea where to install it or what to do with it.
Installation. You can use either python3 setup.py install or pip3 install websocket-client to install. This module is tested on Python 3.7+. There are several optional dependencies that can be installed to enable specific websocket-client features.
Open your Linux terminal or shell. Type “ pip install websocket-client ” (without quotes), hit Enter. If it doesn't work, try "pip3 install websocket-client" or “ python -m pip install websocket-client “. Wait for the installation to terminate successfully.
1.7. The WebSocket protocol is an independent TCP-based protocol. Its only relationship to HTTP is that its handshake is interpreted by HTTP servers as an Upgrade request. By default the WebSocket protocol uses port 80 for regular WebSocket connections and port 443 for WebSocket connections tunneled over TLS [RFC2818].
First, you need to install pip if you don't have it. Type pip
in your terminal or cmd to see if it is installed. Or else, install it first by downloading get-pip.py and executing it.
Then you do pip install websocket
, which will install the module for you.
There seem to be 2 packages in python 3.7: websocket, and websockets. In my case, I tried to install the former but it had to be the latter. Wasted half an hour of my life on that. People who get here might be in the same bag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With