Pygame installs through pip, Python's built-in package manager, in one command
Pygame is a Python library that lets you build games and graphics programs. To use it, you need Python installed first, then you run a single command in your terminal or command prompt to pull Pygame down from the internet and set it up on your machine. The whole process takes a few minutes.
This guide walks you through the exact steps for Windows, Mac, and Linux. If you get stuck at any point, the troubleshooting section covers the most common problems people hit.
Key Takeaways
- You must have Python 3.6 or newer installed before you can install Pygame; check your version by typing python --version in your terminal.
- On Windows, open Command Prompt and type pip install pygame; on Mac or Linux, open Terminal and type the same command.
- If pip is not found, you may need to use pip3 instead of pip, or reinstall Python with the "Add Python to PATH" option checked.
- After installation finishes, test that Pygame works by opening Python and typing import pygame — if no error appears, the installation succeeded.
Check that Python is installed and find its version
Pygame runs on top of Python, so Python must be on your computer first. Open your terminal or command prompt and type python --version, then press Enter. You should see a version number like Python 3.9.0 or higher. If you see "python is not recognized" or a similar error, Python is not installed or not set up correctly — skip to the "Python is not installed" section below.
If you see a version older than 3.6, Pygame will not work with it. You need to download a newer version of Python from python.org, run the installer, and make sure to check the box that says "Add Python to PATH" before clicking Install. This step is easy to miss and causes most installation problems later.
Open your terminal or command prompt in the right place
On Windows: Click the Start button, type "Command Prompt" or "cmd", and press Enter. A black window will open.
On Mac: Open Spotlight by pressing Command + Space, type "Terminal", and press Enter. A white or dark window will open.
On Linux: Right-click on your desktop and select "Open Terminal Here", or open your applications menu and search for Terminal.
You do not need to navigate to any particular folder. The command you are about to run works from anywhere on your system.
Run the pip install command
In the terminal or command prompt window, type this exactly and press Enter:
pip install pygame
Your computer will connect to the internet, download Pygame and its dependencies, and install them automatically. You will see text scrolling past as this happens. This usually takes 30 seconds to 2 minutes depending on your internet speed. When it finishes, you will see a line that says "Successfully installed pygame" or similar.
If you see an error that says "pip is not recognized" or "No module named pip", try typing pip3 install pygame instead. Python 3 sometimes uses pip3 as the command name. If that also fails, see the troubleshooting section.
Test that Pygame installed correctly
Type python or python3 in the same terminal window and press Enter. You should see a prompt that looks like >>>. Now type import pygame and press Enter.
If nothing happens and you see the >>> prompt again, Pygame installed successfully. Type exit() and press Enter to close Python and return to your normal terminal prompt.
If you see an error message like "ModuleNotFoundError: No module named 'pygame'", the installation did not complete. Go back and check the troubleshooting section for the most likely cause.
Troubleshooting: pip is not recognized or not found
This usually means Python was installed without the "Add Python to PATH" option checked. Uninstall Python, download it again from python.org, run the installer, and before clicking Install, check the box labeled "Add Python to PATH". Then click Install and try the pip install pygame command again.
If you do not want to reinstall, you can also try typing the full path to pip directly. On Windows, this is often C:\Users\YourUsername\AppData\Local\Programs\Python\Python39\Scripts\pip install pygame (replace "Python39" with your actual Python version). On Mac and Linux, try /usr/local/bin/pip install pygame. If neither of these works, reinstalling Python with PATH enabled is the fastest fix.
Troubleshooting: Python is not installed or not found
Go to python.org, click the Downloads button, and download the latest version for your operating system. Run the installer. On Windows, before clicking Install, check the box that says "Add Python to PATH" — this is the most important step. On Mac, just follow the prompts. On Linux, Python usually comes pre-installed; if it does not, use your package manager (apt on Ubuntu, brew on Mac with Homebrew, etc.) to install it.
After installation finishes, close and reopen your terminal or command prompt completely, then try python --version again to confirm it worked.
Frequently Asked Questions
Do I need to install anything else before Pygame?
Only Python. Pygame handles all its own dependencies when you run the pip command. You do not need to download or install anything separately.
Can I use Pygame with Python 2?
No. Pygame requires Python 3.6 or newer. If you have Python 2 installed, you need to download and install Python 3. Both can exist on the same computer without conflict.
What if the pip command times out or fails partway through?
Run the command again. pip will pick up where it left off. If it keeps failing, your internet connection may be unstable, or the Python package server may be temporarily down. Wait a few minutes and try again.
How do I update Pygame to a newer version later?
Type pip install --upgrade pygame in your terminal. This downloads and installs the latest version without removing your old one.
Can I install Pygame in a virtual environment instead of system-wide?
Yes. Create a virtual environment with python -m venv myenv, activate it with source myenv/bin/activate (Mac/Linux) or myenv\Scripts\activate (Windows), then run pip install pygame as normal. This keeps Pygame isolated to that project folder.