How to Install pygame in Python

v2.6.1 General Purpose Python >=3.6 LGPL

Python Game Development

Install pip install pygame

What is pygame?

Python Game Development

|AppVeyorBuild| |PyPiVersion| |PyPiLicense| |Python3| |GithubCommits| |BlackFormatBadge| Pygame is a free and open-source cross-platform library for the development of multimedia applications like video games using Python. It uses the and several other popular libraries to abstract the most common functions, making writing these programs a more intuitive task. to make pygame the best it can be! New contributors are welcome. Installation

Before installing pygame, you must check that Python is installed on your machine. To find out, open a command prompt (if you have Windows) or a terminal (if you have MacOS or Linux) and type this: :: python --version If a message such as "Python 3.8.10" appears, it means that Python is correctly installed. If an error message appears, it means that it is not installed yet. You must then go to the `official website ` to download it. Once Python is installed, you have to perform a final check: you have to see if pip is installed. Generally, pip is pre-installed with Python but we are never sure. Same as for Python, type the following command: :: pip --version If a message such as "pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)" appears, you are ready to install pygame! To install it, enter this command: :: pip install pygame Once pygame is installed, quickly test your library by entering the following command, which opens one of the many example games that comes pre-installed: :: python3 -m pygame.examples.aliens If this doesn’t work, the `Getting Started ` section of the official website has more information for platform specific issues, such as adding python to your machine’s PATH settings Help

If you are just getting started with pygame, you should be able to get started fairly quickly. Pygame comes with many tutorials and introductions. There is also full reference documentation for the entire library. Browse the documentation on the . You can also browse the documentation locally by running `` in your terminal. If the docs aren't found locally, it'll launch the online website instead. The online documentation stays up to date with the development version of pygame on GitHub. This may be a bit newer than the version of pygame you are using. To upgrade to the latest full release, run `` in your terminal. Best of all, the examples directory has many playable small programs which can get you started playing with the code right away. Features

Quick Start

Minimal example to get started with pygame:

import pygame

print(pygame.__version__)

Installation

pip (standard)

pip install pygame

Virtual environment (recommended)

python -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate
pip install pygame

pip3

pip3 install pygame

conda

conda install -c conda-forge pygame

Poetry

poetry add pygame

Verify the Installation

After installing, confirm the package is available:

python -c "import pygame; print(pygame.__version__)"

If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.

Installation Errors

Common errors when installing pygame with pip.

ModuleNotFoundError: No module named 'pygame'

Cause: The package is not installed in the current Python environment.

Fix: Run pip install pygame. If using a virtual environment, ensure it is activated first.

ModuleNotFoundError: No module named 'pygame' (installed but still failing)

Cause: pip installed the package into a different Python than the one running your script.

Fix: Use python -m pip install pygame to install into the interpreter you are running.

ImportError: cannot import name 'X' from 'pygame'

Cause: The function or class does not exist in the installed version.

Fix: Check the version with pip show pygame and upgrade with pip install --upgrade pygame.

pip: command not found

Cause: pip is not in PATH or Python was not added to PATH during installation.

Fix: Try python -m pip install pygame. On macOS/Linux try pip3.

PermissionError: [Errno 13] Permission denied

Cause: No write access to the system Python package directory.

Fix: Use a virtual environment, or add --user: pip install --user pygame

SSL: CERTIFICATE_VERIFY_FAILED

Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.

Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pygame

Recent Releases

VersionReleased
2.6.1 latest 2024-09-29
2.6.0 2024-06-25
2.6.0.dev2 2024-06-23
2.5.2 2023-09-17
2.5.1 2023-08-14

Full release history on PyPI →

Manage pygame

Upgrade to latest version

pip install --upgrade pygame

Install a specific version

pip install pygame==2.6.1

Uninstall

pip uninstall pygame

Check what is installed

pip show pygame

Last updated: 2026-04-11 • Data from PyPI