Brendan Boyle
Brendan Boyle

Reputation: 213

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.

Upvotes: 17

Views: 112047

Answers (10)

thuyein
thuyein

Reputation: 1792

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 websockets, which will install the module for you.

Upvotes: 16

Collins Kiragu
Collins Kiragu

Reputation: 1

use pip3 install websockets

That works instead of pip install websockets

Upvotes: 0

user2196346
user2196346

Reputation: 51

This worked for me:

conda install -c conda-forge websockets

Upvotes: 1

ntg
ntg

Reputation: 14075

If you are using pip, as mentioned it is pip install websockets

However, if you are using conda, use: conda install -c conda-forge websockets

Upvotes: 1

Saiful
Saiful

Reputation: 1911

Try with pip install websockets that's work for me!

Upvotes: 0

Ebin Joy
Ebin Joy

Reputation: 3199

For me, nothing worked except Pycharm editor showed a suggestion 'install websocket' which worked(in the import line).

Upvotes: 0

b26
b26

Reputation: 676

Worked on my machine using

pip install "websockets==8.1"

Upvotes: 5

Arwildo
Arwildo

Reputation: 855

If the websocket and websocket-client doesn't work, try:

pip install websocket_client

It works for me.

Upvotes: 8

Badger
Badger

Reputation: 41

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.

Upvotes: 4

fresh
fresh

Reputation: 41

you can also try

pip install websocket-client

Upvotes: 4

Related Questions