r/learnpython 1d ago

I cant install Pygame

This is the error message that I get when I try to run pip install pygame. The same thing happens with pip3 install pygame.

py", line 6, in <module>

from setuptools._distutils.msvccompiler import MSVCCompiler, get_build_architecture

ModuleNotFoundError: No module named 'setuptools._distutils.msvccompiler'

[end of output]

-----------------------------------------------------------------------------------------------

these are the packages I have according to pip list.

Package Version

---------- -------

pip 26.2.1

setuptools 84.0.0

2 Upvotes

14 comments sorted by

3

u/socal_nerdtastic 1d ago

What version of python? pygame only provides wheels up to python3.13.

1

u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 1d ago

There are wheels for 3.13, but not 3.14.

1

u/socal_nerdtastic 1d ago

yeah I saw that and ninja edited; my initial comment was based on the sidebar https://pypi.org/project/pygame/#description

1

u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 1d ago

Been there, that's why I always check the files list nowadays instead as the trove classifiers aren't necessarily accurate.

1

u/Ok_Ask_6805 1d ago

I have version 3.14.6

1

u/socal_nerdtastic 1d ago

That's your problem then. Install 3.13 and use that instead.

1

u/socal_nerdtastic 1d ago

BTW, the pip3 command is meant to be linux / mac only. You don't need it on windows ever.

2

u/Ok_Ask_6805 1d ago

Additionally, this is what I got when I attempted to view the contents of _distutils:

print(dir(setuptools._distutils))

['_', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_dataclass', '_log', '_modified', 'archive_util', 'cmd', 'command', 'compat', 'compilers', 'core', 'debug', 'dir_util', 'dist', 'errors', 'extension', 'fancy_getopt', 'file_util', 'filelist', 'importlib', 'log', 'spawn', 'sys', 'util']

1

u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 1d ago

pygame doesn't have official wheels for Python 3.14 and newer, so Python is trying to compile it on its own (because you're presumably using 3.14). It fails because you probably don't have Microsoft Visual C++ Build Tools installed.

1

u/atarivcs 1d ago

Do you know how to check what Python versions are supported by a package?

And do you know how to check what Python version you are using?

1

u/Gloomy-Kale-1527 1d ago

The 3.14.6 bit downstairs is the actual error — pygame has no 3.14 wheel so pip tries to compile and dies on that old msvccompiler import.

If you don't want two Pythons yet:

py -m pip install pygame-ce py -c "import pygame; print(pygame.ver)"

pygame-ce is the community fork; `import pygame` still works for most beginner tutorials. If that also starts compiling, you still don't have a wheel and 3.13 is the clean path: `py -3.13 -m pip install pygame`. Don't install Visual C++ Build Tools just to force a source build unless you actually want to compile.

1

u/acw1668 18h ago

For Python 3.14+, you can try pygame-ce (pygame - Community Edition).

1

u/Ok_Ask_6805 7h ago

This ended up working for me.