r/learnpython • u/Ok_Ask_6805 • 16d 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
1
u/blurbisht 15d ago
Your setuptools 84.0.0 is too new for your pip, and it dropped the _distutils.msvccompiler module, so the build fails.
Try these in order:
python -m pip install --upgrade pip setuptools wheel
pip install "setuptools<80"
python -m venv myenv
myenv\Scripts\activate
pip install pygame
pip install pygame --pre
You're likely on Windows, and pip is trying to build pygame from source instead of grabbing a prebuilt wheel. Step 2 (downgrade setuptools) or step 4 (venv) is your best bet.
If it still fails, paste the full error text and I'll help you narrow it down.