How to install Pygame using PIP or an IDE
We will see in this tutorial how to install the pygame module on Windows or MAC using pip or the PyCharm editor.
Introduction
When you’re new to Python programming, the best way to improve your skills is to create mini-games. This allows you to have fun while learning the basics of programming. To develop a game in Python, there are several modules that make it easier to work with graphics (such as rectangles, circles, images, etc…) and sounds. Pygame is one of them.
Pygame is a Python wrapper for the SDL (Simple DirectMedia Layer) library. SDL provides cross-platform access to the underlying multimedia hardware components of your system, such as sound, video, mouse, keyboard and joystick. You can therefore program games and Python programs with Pygame that are supported on different platforms.
By default, Pygame is not installed on the Python programming environment. We will therefore see in this guide the best instructions for installing it on your system.
If you wish to deepen your knowledge in the Pygame Module, I invite you to read this book :
As an Amazon Associate I earn from qualifying purchases. If you purchase a product by using a link on this page, I’ll earn a small commission at no extra cost to you
No products found.
How to install Pygame for Windows
Install Python
To run the Pygame module, we must have a version of Python on our machine. If you haven’t already done so, it is available here :

Download Latest Version of Python
Click on the version of Python you are interested in and press download. You can install the latest stable version of Python.
Once the download is complete, press the run button. Check the box ”Add Python 3.5 to PATH”.
Make sure the checkboxes for “Optional features” are checked. For the rest, you can leave them as they are. To finalize the installation, press the install button for your computer to complete the installation.
Install Module Pygame
You can get a version of Pygame via this link :
Take the latest version available and click on the link to download the .whl file to your computer.
pygame‑1.9.6‑cp39‑cp39‑win32.whl
You can choose between a 32bits or 64bits version (in this example, we will start with the win32 version).
To install the previously downloaded Pygame module, we need to access the Windows command line.
To access it, right-click on the started menu and click on Execute. Then type on the text box “cmd“.
Then go to the directory where you installed the Pygame module (by default in the Downloads folder).
Once you are in the right folder, type the following command prompt:
To check that the installation has worked, type the following command prompt:
If you do not see any error messages, the installation went well.
How to install Pygame for OS X
The first step to do is to access the command line. To do so, click on the Spotlight icon and type “terminal” to find it.
We will install XCode (which is an Apple tool for creating Mac and iOS applications. Once the installation is complete, type the following command prompt:
Install Homebrew
Homebrew is a package manager for Mac that simplifies the installation of many different software or packages such as Git, Python or Pygame. Homebrew allows you to avoid possible security issues related to the use of the sudo command to install software like Node.
To install it, copy and paste this on the command prompt:
You will also need to install Homebrew Cask :
Install pygame and these Requirements
To install pygame, we must first install all the pygame dependencies. To do this, please run the following commands one at a time:
As you can see, we have installed python 3 and the pygame module. To check that the installation has been successful, type the following commands:
If you don’t get any error messages, it means that the installation was successful.
How to install Pygame using PyCharm IDE
PyCharm is an integrated development environment (IDE) used in computer programming, specifically for the Python language. PyCharm is cross-platform, with Windows, macOS and Linux versions.
To start opening Pycharm and create a new python project. Then create a python file by right-clicking on the project then New then Python file. Name your python file as you wish.
In your python file, type the following line :
You will see that the pygame is underlined in red. To install pygame, move the mouse over the red underlined area and click on “install package pygame“.
Wait for Pycharm to install pygame and that’s it !

PyCharm IDE : How to install pygame module
Conclusion
In this tutorial, we have seen how to install pygame on Windows, OS X and using an IDE like PyCharm. Now it’s up to you to create your first 2D mini-game!
Here is an example of what you can do with Pygame :
Don’t hesitate to tell me in the comments if you have problems with the pygame installation. And also, I would be happy to see your future projects on pygame!
I’m a data scientist. Passionate about new technologies and programming I created this website mainly for people who want to learn more about data science and programming 🙂
Add pygame module in PyCharm IDE
I’ve downloaded pygame-1.9.1release.tar.gz from the Pygame website. I extracted and installed it and it’s working fine in the command line Python interpreter in Terminal (Ubuntu). But I want to install it for some IDE, like PyCharm. How can I do it?
![]()
![]()
5 Answers 5
Well, you don’t have to download it for PyCharm here. You probably know how it checks your code. Through the interpreter! You don’t need to use complex command lines or anything like that. You need to is:
Download the appropriate interpreter with PyGame included
Open your PyCharm IDE (Make sure it is up to date)
Press Settings (Or Ctrl + Alt + S)
Double click on the option that looks like Project: Name_of_Project
Click on Project Interpreter
Choose the interpreter you want to use that includes PyGame as a module
Save your options
And you are ready to go! Here is an alternate (I have never done this, please try to test it)
- Add PyGame in the same folder as your PyCharm file (Your PyCharm stuff is always in a specific file placed by you during installation/upgrade) Please consider putting your PyCharm stuff inside a folder for easy access.
I hope this helps you!
![]()
For PyCharm 2017 do the following:
- File — Settings
- Double click on your project name
- Select Project Interpreter
- Click on green + button on the right side of the window
- Type Pygame in search window
- Click Install package.
Not I’m saying that the answers above won’t work, but it might be frustrating to a newbie to do command line magic.
If you are using PyCharm and you are on a Windows 10 machine use the following instructions:
Click on the Windows start menu and type cmd and click on the Command Prompt icon.
Use the command pushd to navigate to your PyCharm project which should be located in your user folder on the C:\ drive. Example: C:\Users\username\PycharmProjects\project name\venv\Scripts.
(If you are unsure go to the settings within PyCharm and navigate to the Python Interpreter settings. This should show you the file path for the interpreter that your project is using. Credit to Anthony Pham for instructions to navigate to interpreter settings.)
HINT: Use copy and paste in the command prompt to paste in the file path.
Use the command pip install pygame and the pip program will handle the rest for you.
Restart you Pycharm and you should now be able to import pygame
Hope this helps. I had a fun time trying to find out the correct way to get it installed, so hopefully this helps someone out in the future.