Python can not find the installed package pygame

Hello there, I am new to python and new to this platform. If I am asking something stupid and/or in the wrong section, please be gentle with me - thanks a lot!

I am currently experiencing problems with python when trying to use the module “pygame”.

I am running Python 3.10.11 on a Windows 11 Pro operating system. I did install pygame via “pip3.10 install pygame”. When checking for the pygame-version, I am receiving the following answer:

C:\Users\bernh>python -m pip install --upgrade pygame

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

However, when running Python (both interactively via IDLE or in the script modus), I am getting the error message that this module cannot be found:

import pygame

Traceback (most recent call last):
File “<pyshell#1>”, line 1, in

  • import pygame*
    ModuleNotFoundError: No module named ‘pygame’

Any idea on what the problem could be and/or how I could fix this problem?

Thanks a lot for your time and help. All the best!

This happens because you have more than one Python on your computer, and the one where you have installed Pygame is not the one you are running for your tests. Each Python has its own copy of pip, to install libraries for that Python only. pip3.10 install pygame means: ask the operating system to look up the program name pip3.10, and then install pygame to the Python that this pip corresponds to. This may not be the same Python that you get by asking the operating system to find py, or python, or python3, or even python3.10. It will depend on your system configuration. (Although py is a special case; it is a separate program that is not itself Python, which will find and run a Python for you, based on its own rules.)

Thanks a lot, this solved my problem.