Home > Net >  Can`t import pygame to VScode despite having it installed
Can`t import pygame to VScode despite having it installed

Time:10-06

I'm using pip 21.2.4 and python 3.9.7

I'm pretty sure I have pip installed since if I run pip --version in the terminal it gives me pip 21.2.4 from C:\Users\rohaan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pip (python 3.9)

If I run pip install pygame in the terminal I get Requirement already satisfied: pygame in c:\users\rohaan\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (2.0.1)

Despite the requirement being satisfied when I import pygame I get ModuleNotFoundError: No module named 'pygame'

Does anybody know how to fix this?

CodePudding user response:

This means you have multiple versions of python installed on your device, one has the module and the other tries to run the file, go to the control panel and check it out.

CodePudding user response:

It looks like you are not using the python interpreter which you have installed the pygame package.

You can execute this code to verify which python interpreter you are using:

import sys
print(sys.executable)

Then you can switch the python interpreter to which you have installed the packages or you need to activate the environment before you want to install the package in order to install the package to the right place.

enter image description here

  • Related