0

I recently upgraded to Python 3.9. However, I wish to run an asyncio websockets client which starts with

import websockets

However, when I attempt to run the code, I get the following:

ModuleNotFoundError: No module named 'websockets'

However, if I attempt to install websockets using pip3, I see that it is already installed on my system but in a different location to my python installation:

websockets: ./.local/lib/python3.9/site-packages
Python 3.9: /opt/python/3.9.6/bin/python3

Does anyone know how I can resolve this? I am not using any virtual environment, and I am running Linux.

Thanks in advance

tjsmert44
  • 121
  • 1
  • 12
  • How are you trying to run your script? Like is it from the console or from something GUI? – Rashid 'Lee' Ibrahim Nov 03 '21 at 18:20
  • Using `python -m pip install` will ensure that the `pip` used corresponds to the same version of Python as `python`. See the linked duplicate for details. Your `pip3` installs to that wrong location because it comes from that installation of Python, which is separate from the one you wanted to use. BTW, now is a good time to learn about virtual environments, and about managing multiple Python distributions in general. – Karl Knechtel Nov 03 '21 at 18:24
  • @Rashid'Lee'Ibrahim I am just running the script in the console just via ```python3 test.py``` – tjsmert44 Nov 04 '21 at 08:39

0 Answers0