How to Install Pygame on Windows

In this tutorial we will explain how you can install the Python library Pygame on your Windows device.

Pygame is a gaming library in Python that specializes in the creation of 2-D games. It has support for many important features required to make games, such as Audio, Collision detection, Event system and much more. You can learn more about Pygame here.


Setting up Pygame on Windows

To setup Pygame on Windows, all you have to do is run the following command.

pip install pygame

If this command is executed successfully, create a new Python .py file with the following code.

import pygame

If this import statement executes without throwing an error, it means the Pygame module was successfully installed on your windows device.


Potential Problems

You may face some problems while running the pip install command. For one, the latest versions of Pygame have dropped support for Python2. This could potentially be causing some problems.

The more likely reason behind any problem however, is that you do not have the Python Installation Directory added into PATH (environment variables).

The above image shows you where you can find the environment variables button. You can pull up this menu by searching for “advanced system settings” or “environment variables” in the Windows Search Bar.

Once this Window is open, selected “Path” from System variables and click on edit. This will bring up a list of file paths that have been saved to Path.

Now you need to find the filepath where your Python.exe file is stored, and add it into this list.

The above image shows you my Python installation path added to Path.


This marks the end of the Install Pygame on Windows Tutorial. Any suggestions or contributions for CodersLegacy are more than welcome. Questions regarding the tutorial content can be asked in the comments section below.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments