'No module named "pygame" after using pip

I am a beginner and I want to work with the pygame module. I have already used pip install to install pygame and it says so on my command prompt. On my command prompt it says:

Requirement already satisfied: pygame in c:\users\35192\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (2.1.2)

However, when I try to import pygame in vscode, the module won't import and it says: "ModuleNotFoundError: No module named 'pygame'"

Does anyone know how to fix this?



Solution 1:[1]

I solved the problem. I basically just used Ctrl+Shift+P to open up the command palette. From there, I opened "Python: Select interpreter" and then I just changed the python interpreter to be the global one (which I assume is the one used by the command prompt)

Solution 2:[2]

As seen here: https://stackoverflow.com/questions/15185827/can-pip-be-used-with-python-tools-in-visual-studio#:~:text=Go%20to%20Tools%20-%3E%20Python%20Tools%20-%3E%20Python,enter%20your%20module%20and%20double%20click%20to%20install.

You have to go to Tools -> Python Tools -> Python Environments in vs code. Then click on your python installation, then pip, and install pygame.

Or you can find where your vs code python installation is, and run this: "directory to vs code python.exe" -m pip install pygame

If you would like to use one python installation everywhere, you can change your vs code interpreter/environment to the python you already have installed on your system. As seen here: https://code.visualstudio.com/docs/languages/python

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 António Rebelo
Solution 2