Last Updated :
21 Feb, 2023
In this article, we will learn how to Install PyGame module of Python on Windows. PyGame is a library of python language. It is used to develop 2-D games and is a platform where you can set python modules to develop a game. It is a user-friendly platform that helps to build games quickly and easily.
Follow the steps given below for the successful installation of Pygame
Step 1: Check for Python Installation
In order to install Pygame, Python must be installed already in your system. To check whether Python is installed or not in your system, open the command prompt and give the command as shown below.
If this command runs successfully, and we are able to get a Python version then we are good to go. Otherwise, we have to install Python in our system, to do this refer to How to install Python on Windows?
Step 2: Check for PIP installation
PIP is a tool that is used to install python packages. PIP is automatically installed with Python 2.7. 9+ and Python 3.4+. Open the command prompt and enter the command shown below to check whether pip is installed or not.
Note: Refer to How to install PIP on Windows ? for detailed information.
Step 3: Install Pygame
To install Pygame, open the command prompt and give the command as shown below:
pip install pygame
Pygame is successfully installed as shown in the image above.
Step 4: Check Whether PyGame is Working or not
Now open a new terminal and import the Pygame library to see whether it is working fine or not in our system. The library is imported successfully means we got success.
In this way, we can install the pygame module in Python.
Pygame is a free, open‑source library for making multimedia applications (most notably games) in Python. It wraps the popular SDL library, giving you easy access to graphics, sound, and input devices.
Whether you’re building your first arcade clone or prototyping a complex UI, Pygame provides the foundation to bring your ideas to life.
However, before installing Pygame, make sure you have Python 3.7+ installed. You can download from python.org. This obviously means that internet connection is a must have.
Read: How To Install Seaborn On Python 3.13.3 [2025]
Install Pygame In Windows
The most straightforward method, however, uses pip, which is the standard package manager for Python that can be use to download, update and manage the standard package libraries. Follow these steps to install Pygame using pip:
Start by ensuring you have the latest version of Python installed on your computer. If you haven’t, here’s how.
Next, verify the version of Python you’re running, type cmd in your computer’s search bar and press enter or select Run as Administrator.
Here, enter the command, python –version and hit enter. As at May 2025, the latest version should return Python 3.13.3.
It’s also a good idea to have the latest pip version. For the pip version, type pip –version in the cmd line. As at May 2025, the latest version should return pip 25.1.1.
In the next command line, type pip install pygame and press Enter.
Give the package a few moments to install. You should receive a message that Pygame has been successfully installed.
Watch: How To Install Seaborn On Python 3.13.3
About The Author
Erick Wachira
Based in Nairobi, Kenya, I am a tech enthusiast who travels down the forgotten road of tutorials regarding everyday tech. We all use our smartphones, TVs, Bluetooth devices, PCs and many more tech devices in our day-to-day. With that, comes issues from time-to-time that need a solution you may not have though of, or might have overlooked. This is where I come in. To the rescue as I offer you solutions and troubleshooting steps to everyday tech problems.
Pygame is a free and open-source cross-platform library
for the development of multimedia applications like video games using Python.
It uses the Simple DirectMedia Layer library and several other
popular libraries to abstract the most common functions, making writing
these programs a more intuitive task.
We need your help 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 docs page. You
can also browse the documentation locally by running
python -m pygame.docs 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
pip install pygame —upgrade 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
Pygame is a powerful library for game development, offering a wide
range of features to simplify your coding journey. Let’s delve into
what pygame has to offer:
Graphics — With pygame, creating dynamic and engaging graphics has
never been easier. The library provides simple yet effective tools for
2D graphics and animation, including support for images, rectangles,
and polygon shapes. Whether you’re a seasoned game developer or just
starting out, pygame has you covered.
Sound — Pygame also includes support for playing and manipulating sound
and music, making it easy to add sound effects and background music to
your games. With support for WAV, MP3, and OGG file formats, you have
plenty of options to choose from.
Input — Pygame provides intuitive functions for handling keyboard, mouse,
and joystick input, allowing you to quickly and easily implement player
controls in your games. No more struggling with complex input code, pygame
makes it simple.
Game Development — Lastly, pygame provides a comprehensive suite of tools
and features specifically designed for game development. From collision
detection to sprite management, pygame has everything you need to create
exciting and engaging games. Whether you’re building a platformer, puzzle
game, or anything in between, pygame has you covered.
Building From Source
If you want to use features that are currently in development,
or you want to contribute to pygame, you will need to build pygame
locally from its source code, rather than pip installing it.
Installing from source is fairly automated. The most work will
involve compiling and installing all the pygame dependencies. Once
that is done, run the setup.py script which will attempt to
auto-configure, build, and install pygame.
Much more information about installing and compiling is available
on the Compilation wiki page.
Contribute
-
Documentation Contributions — Guidelines for contributing to the main documentations
-
Writing your first unit test — Step by step guide on how to write your first unit test in Python for Pygame.
-
How to Hack Pygame — Information on hacking, developing, and modifying Pygame
-
Issue Tracker for beginners — A way for beginners to contribute to the project
-
Bugs & Patches — Report bugs
-
Communication tools — More information and ways to get in touch with the Pygame team
Credits
Thanks to everyone who has helped contribute to this library.
Special thanks are also in order.
-
Marcus Von Appen: many changes, and fixes, 1.7.1+ freebsd maintainer
-
Lenard Lindstrom: the 1.8+ windows maintainer, many changes, and fixes
-
Brian Fisher for svn auto builder, bug tracker and many contributions
-
Rene Dudfield: many changes, and fixes, 1.7+ release manager/maintainer
-
Phil Hassey for his work on the pygame.org website
-
DR0ID for his work on the sprite module
-
Richard Goedeken for his smoothscale function
-
Ulf Ekström for his pixel perfect collision detection code
-
Pete Shinners: original author
-
David Clark for filling the right-hand-man position
-
Ed Boraas and Francis Irving: Debian packages
-
Maxim Sobolev: FreeBSD packaging
-
Bob Ippolito: MacOS and OS X porting (much work!)
-
Jan Ekhol, Ray Kelm, and Peter Nicolai: putting up with early design ideas
-
Nat Pryce for starting our unit tests
-
Dan Richter for documentation work
-
TheCorruptor for his incredible logos and graphics
-
Nicholas Dudfield: many test improvements
-
Alex Folkner for pygame-ctypes
Thanks to those sending in patches and fixes: Niki Spahiev, Gordon
Tyler, Nathaniel Pryce, Dave Wallace, John Popplewell, Michael Urman,
Andrew Straw, Michael Hudson, Ole Martin Bjoerndalen, Herve Cauwelier,
James Mazer, Lalo Martins, Timothy Stranex, Chad Lester, Matthias
Spiller, Bo Jangeborg, Dmitry Borisov, Campbell Barton, Diego Essaya,
Eyal Lotem, Regis Desgroppes, Emmanuel Hainry, Randy Kaelber
Matthew L Daniel, Nirav Patel, Forrest Voight, Charlie Nolan,
Frankie Robertson, John Krukoff, Lorenz Quack, Nick Irvine,
Michael George, Saul Spatz, Thomas Ibbotson, Tom Rothamel, Evan Kroske,
Cambell Barton.
And our bug hunters above and beyond: Angus, Guillaume Proux, Frank
Raiser, Austin Henry, Kaweh Kazemi, Arturo Aldama, Mike Mulcheck,
Michael Benfield, David Lau
There’s many more folks out there who’ve submitted helpful ideas, kept
this project going, and basically made our life easier. Thanks!
Many thank you’s for people making documentation comments, and adding to the
pygame.org wiki.
Also many thanks for people creating games and putting them on the
pygame.org website for others to learn from and enjoy.
Lots of thanks to James Paige for hosting the pygame bugzilla.
Also a big thanks to Roger Dingledine and the crew at SEUL.ORG for our
excellent hosting.
Dependencies
Pygame is obviously strongly dependent on SDL and Python. It also
links to and embeds several other smaller libraries. The font
module relies on SDL_ttf, which is dependent on freetype. The mixer
(and mixer.music) modules depend on SDL_mixer. The image module
depends on SDL_image, which also can use libjpeg and libpng. The
transform module has an embedded version of SDL_rotozoom for its
own rotozoom function. The surfarray module requires the Python
NumPy package for its multidimensional numeric arrays.
Dependency versions:
CPython |
>= 3.6 (Or use PyPy3) |
SDL |
>= 2.0.8 |
SDL_mixer |
>= 2.0.0 |
SDL_image |
>= 2.0.2 |
SDL_ttf |
>= 2.0.11 |
SDL_gfx |
(Optional, vendored in) |
NumPy |
>= 1.6.2 (Optional) |
License
This library is distributed under GNU LGPL version 2.1, which can
be found in the file docs/LGPL.txt. We reserve the right to place
future versions of this library under a different license.
This basically means you can use pygame in any project you want,
but if you make any changes or additions to pygame itself, those
must be released with a compatible license (preferably submitted
back to the pygame project). Closed source and commercial games are fine.
The programs in the examples subdirectory are in the public domain.
See docs/licenses for licenses of dependencies.
Pygame is a popular library for creating games in Python. It provides tools for handling graphics, sound, and user input. This guide will help you install Pygame and troubleshoot common issues.
Prerequisites
Before installing Pygame, ensure you have Python installed. You can check this by running python --version
in your terminal. If Python is not installed, download it from the official website.
Installing Pygame
To install Pygame, use the pip
package manager. Open your terminal or command prompt and run the following command:
pip install pygame
This command downloads and installs the latest version of Pygame. Once the installation is complete, you can verify it by importing Pygame in a Python script.
Verifying the Installation
Create a new Python file and add the following code to verify the installation:
import pygame
print("Pygame installed successfully!")
Run the script. If you see the message «Pygame installed successfully!», the installation was successful.
Common Errors and Fixes
Sometimes, you may encounter errors like ModuleNotFoundError: No module named ‘pygame’. This usually happens if Pygame is not installed correctly or in the wrong environment.
To fix this, ensure you are using the correct Python environment. If you are using a virtual environment, activate it before running the installation command. For more details, check our guide on How to Fix ModuleNotFoundError: No module named ‘pygame’.
Example: Creating a Simple Pygame Window
Let’s create a simple Pygame window to test the installation. Copy the following code into a Python file:
import pygame
# Initialize Pygame
pygame.init()
# Set up the display
screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption("Pygame Window")
# Main loop
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Fill the screen with a color
screen.fill((0, 0, 255))
pygame.display.flip()
# Quit Pygame
pygame.quit()
Run the script. A blue window titled «Pygame Window» should appear. This confirms that Pygame is working correctly.
Conclusion
Installing Pygame is straightforward with pip
. However, errors like ModuleNotFoundError can occur if the installation is not done correctly. Follow this guide to ensure a smooth setup.
Once installed, you can start building games with Pygame. For more advanced topics, explore the official Pygame documentation or check out our other tutorials.
Edit me
Pygame is a set of Python modules used for writing simple video games and graphical programs. It is cross-platform, which means it can be installed on both Windows and Mac computers. This guide provides the steps needed to install Pygame for Python 3.6 on Windows and macOS.
Procedure (Windows 10)
- Make sure to have the latest version of Python 3 installed on your computer. If you need to install Python 3, you can visit (this site) to install the latest Python 3 release.
-
When running the Python installer, you will have to select Customize installation. Click Next and check the box next to Install for all users at the top of the list in Advanced Options. You can now click Install.
- Once Python 3 is installed, launch the File Explorer.
-
Click This PC, select the drive where Windows is installed (usually the C:\ drive), double-click on the Program Files (x86) folder, and double-click on the Python folder (i.e. Python36-32).
-
Click on the path in the text box towards the top of the File Explorer window and copy it to the clipboard.
- Next, you will need to launch the Control Panel. To do this, open the Start Menu and search control in the search box. The Control Panel should be the first option that appears in the Start Menu.
- Click on System and Security, then System, then Advanced System Settings.
-
In the window that appears, click on Enviroment Variables…
-
You will need to edit the Path system variable. To do this, select Path in the System variables section of the window and click Edit…
- Click New and paste the path copied from earlier into the empty textbox that is generated. Click OK twice to save the changes.
- You will now need to open the Command Prompt as an administrator. To do this, open the start menu and search cmd in the search box. The Command Prompt should be the first option that appears in the Start Menu. Right click on that option and choose Run as administrator.
- In the Command Prompt, type cd and a space and right-click in the Command Prompt to paste the path to Python. Press Enter.
- Type this command into the Command Prompt and press Enter:
- You can now install Pygame. To do this, type the following command and press Enter:
- Pygame should have successfully installed. To verify this, type the following command to launch the Python interactive interpreter:
- Type the following line in the interpreter and press Enter:
If entering the previous line into the interpreter does not throw any errors, you have successfully installed Pygame on Windows. You can now write any graphical program you want using the Pygame library.
Procedure (Mac OS X)
This guide is based on an article found (here)
- Before installing Pygame, there are many dependencies that will need to be installed. Begin by installing the XCode developer tools, which can be done through the app store.
- Next you will need to install the latest version of XQuartz. You can start the installation by visiting the site (here).
-
Open a Terminal window. This can be done by pressing command+Space (⌘+Space) and typing Terminal in the search bar and pressing Enter.
- You now need to install Homebrew. You can do this by typing the following command in the Terminal and pressing Enter:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- After the installation is finished, you will need to type the following commands in the Terminal, pressing Enter after each one:
echo export PATH='usr/local/bin:$PATH' >> ~/.bash_profile
- You can now install Python 3 using Homebrew. To do this, type the following command in the Terminal and press Enter:
- Now you need to install several dependencies for Pygame. Type the following commands in the Terminal, pressing Enter after each one:
brew install sdl sdl_image sdl_mixer sdl_ttf portmidi
brew tap homebrew/headonly
- You are ready to install Pygame. Type the following command in the Terminal and press Enter. Note that you will probably have to enter your password in the Terminal in order for the command to run:
sudo pip3 install hg+http://bitbucket.org/pygame/pygame
- To verify the installation, you will have to launch the correct version of IDLE. You can find this by opening Finder, clicking on Go in the top left of the screen, then clicking on the Go to Folder… option.
- In the search bar, enter /usr/local/Cellar/python and click Go.
- Navigate to the folder where Python 3 is located. It will probably be named in this format: 3.x.x.
- Launch the IDLE 3 app within the folder. When launched, it should be using Python 3.x.x.
- In the IDLE interpreter, type the following command and press Enter:
If the command completed without throwing any errors, you have successfully installed Pygame and found the correct version of IDLE to use for Pygame programming.
- To make finding this version of IDLE easier, you can create a Desktop shortcut for IDLE 3. If you want to do this, press and hold the control key and click on IDLE 3. It will open a Menu where you can select Make Alias and create another IDLE 3 icon. You can name this icon whatever you like, but make sure to drag it to your Desktop when you are done.