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.

2 min readUpdated
On this page

1. Use python -m pip#

Plain pip may belong to another Python or not be on your PATH. Always use:

Terminal
python -m pip install pygame     # macOS/Linux may need python3
py -m pip install pygame         # Windows with the py launcher

If 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#

Terminal
python --version

pip 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:

Terminal
python -m pip install --upgrade pip
python -m pip install pygame

4. Read the actual error#

You seeGo to
error: externally-managed-environmentUse a virtual environment (Linux, macOS).
Building wheel for pygame ... error, sdl2-config, Microsoft Visual C++ 14.0 is requiredNo wheel for your setup: pip install errors.
Permission denied, Access is deniedUse a virtual environment or python -m pip install --user pygame. Don't use sudo pip.
Could not find a version that satisfies the requirement pygameYour Python is too old, 32-bit on an unsupported platform, or pip can't reach PyPI.
SSL: CERTIFICATE_VERIFY_FAILEDFix certificates (macOS: run Install Certificates.command) or your network's proxy settings.
Timeouts or ProxyErrorCorporate 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:

Terminal
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.aliens

If this works, your original environment was the problem.

6. Still stuck?#

  • Make sure you're installing pygame or pygame-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.
↑ ↓ to moveEnter to openEsc to close