Install Pygame on Windows
Install Python, then Pygame with one command, and fix the PATH and "pip is not recognized" problems that trip up most Windows users.
On this page
Step 1: Install Python#
- Download the latest Python 3 installer for Windows from python.org/downloads. Check the download page for which Python versions currently have Pygame wheels.
- Run the installer. On the first screen, tick Add python.exe to PATH, then click Install Now.
- When it finishes, open a new Command Prompt or PowerShell window (existing windows don't see the updated PATH).
The python.org installer also installs the py launcher, which picks the right Python even when PATH is messy. The commands below use py; if you prefer, python works the same when it's on your PATH.
On a fresh Windows install, typing python may open the Microsoft Store instead of running Python. That's an "app execution alias". Either install Python from python.org as above, or turn off the aliases in Settings → Apps → Advanced app settings → App execution aliases.
Step 2: Install Pygame#
In Command Prompt or PowerShell:
py -m pip install pygameor, for the community edition:
py -m pip install pygame-ceYou should see pip download a file ending in win_amd64.whl and finish with Successfully installed. If it instead starts "Building wheel" and fails, see pip install errors: your Python version probably has no prebuilt Pygame package yet.
Step 3: Check it works#
py -c "import pygame; print(pygame.version.ver)"
py -m pygame.examples.aliensUsing a virtual environment (recommended)#
cd C:\path\to\your\game
py -m venv .venv
.venv\Scripts\activate
python -m pip install pygameThe prompt shows (.venv) while the environment is active. If PowerShell refuses to run activate because scripts are disabled, either use Command Prompt, or allow local scripts for your user:
Set-ExecutionPolicy -Scope CurrentUser RemoteSignedCode editors#
In VS Code, install the Python extension, then use Python: Select Interpreter to pick the same Python (or .venv) you installed Pygame into. Most "No module named pygame" reports on Windows come from the editor using a different interpreter. IDLE, which comes with Python, always uses the Python it was installed with.
Common Windows problems#
| Problem | Fix |
|---|---|
'pip' is not recognized as an internal or external command | Use py -m pip instead of pip. |
'python' is not recognized | Use py, or reinstall Python with "Add python.exe to PATH". |
No module named pygame in VS Code but it works in the terminal | Select the right interpreter in VS Code. More fixes. |
Defaulting to user installation because normal site-packages is not writeable | Harmless: pip installed for your user only. |
| Several Python versions installed | py -0 lists them; py -3.13 -m pip install pygame targets one. |