Pygame won't install
Work through these checks in order. Almost every failed installation comes down to the pip command, the Python version or the environment.
On this page
1. Use python -m pip#
Plain pip may belong to another Python or not be on your PATH. Always use:
python -m pip install pygame # macOS/Linux may need python3
py -m pip install pygame # Windows with the py launcherIf python itself isn't found, Python isn't installed or isn't on your PATH. Follow the guide for Windows, macOS or Linux.
2. Check your Python version against available wheels#
python --versionpip installs Pygame instantly when a prebuilt wheel exists for your Python version and system. The download page lists which versions have wheels. If yours is newer than the newest listed, pip falls back to compiling from source, which usually fails on a normal computer. Either install a supported Python alongside, or try pygame-ce, which often supports new versions sooner. Details in Python compatibility.
3. Upgrade pip#
Old pip versions don't recognise newer wheel formats and try to build from source:
python -m pip install --upgrade pip
python -m pip install pygame4. Read the actual error#
| You see | Go to |
|---|---|
error: externally-managed-environment | Use a virtual environment (Linux, macOS). |
Building wheel for pygame ... error, sdl2-config, Microsoft Visual C++ 14.0 is required | No wheel for your setup: pip install errors. |
Permission denied, Access is denied | Use a virtual environment or python -m pip install --user pygame. Don't use sudo pip. |
Could not find a version that satisfies the requirement pygame | Your Python is too old, 32-bit on an unsupported platform, or pip can't reach PyPI. |
SSL: CERTIFICATE_VERIFY_FAILED | Fix certificates (macOS: run Install Certificates.command) or your network's proxy settings. |
Timeouts or ProxyError | Corporate network: set --proxy http://user@proxy:port, or ask your IT department. |
5. Start clean with a virtual environment#
A fresh environment rules out leftover packages and permission problems:
python -m venv pg-test
# Windows: pg-test\Scripts\activate macOS/Linux: source pg-test/bin/activate
python -m pip install --upgrade pip
python -m pip install pygame
python -m pygame.examples.aliensIf this works, your original environment was the problem.
6. Still stuck?#
- Make sure you're installing
pygameorpygame-ce, not similarly named packages. - On a locked-down school or work computer, use Pygame Online instead.
- Search the pip error message on the pygame issue tracker or pygame-ce issue tracker. Include your Python version, operating system and the full pip output if you ask for help.