Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named 'websocket'

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.

like image 890
Brendan Boyle Avatar asked Dec 06 '17 02:12

Brendan Boyle


People also ask

How do I install a Websocket module?

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.

How do I install a Websocket in Python?

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.

Is Websocket a protocol?

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].


2 Answers

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.

like image 116
thuyein Avatar answered Sep 23 '22 12:09

thuyein


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.

like image 33
Badger Avatar answered Sep 23 '22 12:09

Badger