Python pygame not installing

Short answer

pip install pygame --pre is necessary right now due to your Python version

Long answer

Your traceback shows you are using Python 3.11, which was just released earlier today. Pygame is a “C extension” and needs to re-release itself with new “wheels” (binaries) for every new minor release of Python (3.9, 3.10, 3.11, etc.)

The latest “full” pygame release, 2.1.2, was released a while back and doesn’t come with wheels for 3.11, so your system tries to build pygame from source. It fails to do so, because you don’t have a pygame development environment set up.

However, the latest pre release of pygame, 2.1.3.dev8 (released recently) has wheels for 3.11, so your system will not need to compile pygame from source.

Once pygame 2.1.3 is released, this extra flag (which tells it to look for pre releases), won’t be necessary.

Leave a Comment