Pygame is a Python module for writing simple video games and graphical programs. It is popular for its simplicity and ease of use. Pygame is free and open source, and works on Windows, Mac OS X, Linux, Android and iOS.
Installing pygame is easy; you can follow the steps below.
- Download the pygame installer from Pygame’s website.
- Run the installer.
- Follow the prompts to complete installation.
- Verify installation by opening a Python shell and running
What is Pygame?
Pygame is a cross-platform set of Python modules designed for writing video games. It includes computer graphics and sound libraries designed to be used with the Python programming language.
This document describes how to install Pygame for Python 3.5. It assumes you already have a Python interpreter installed on your system. If you don’t have one, please go to https://www.python.org/ and download and install the latest release for your operating system.
- Go to https://www.pygame.org/download.shtml and look for the section that says “Downloads for Windows”.
- Click on the link that says “pygame-1.9.6a0.win32-py3.5.msi”.
- This will start the download of a file called “pygame-1.9.6a0.win32-py3.5.msi”. Once the download is complete, double-click on this file to start the pygame installer wizard and follow the instructions given by the wizard
Mac OS X
Assuming you have a recent version of Pygame already installed,
download the appropriate “.dmg” file for your version of Python
from the downloads page.
Open the file, and drag the pygame folder inside of it to your Applications folder.
You should see a new pygame icon inside of your Applications folder. Congrats, you’ve installed Pygame!
- Open a terminal window and type: sudo apt-get install python3-pygame
- Press Enter
- The following Additional information about this package will be displayed:
Python-pygame will also install several support libraries required by pygame. These include SDL_ttf, SDL_mixer and smpeg. Once you have installed the python-pygame package, you should be able to import the pygame modules in your python scripts.
Installing Pygame is easy; you can install it from source, or from one of the binary installers available for your platform. On Linux and Mac OS X you should already have Python installed; Windows users may need to download and install it before proceeding.
Once you have Python installed, open a terminal (or command line console on Windows) and type the following:
pip install pygame
This will download and install Pygame for your system. If you run into any problems, please see the troubleshooting page for help.
In this tutorial, you’ve learned how to install Pygame for Python 3.5 on Windows and macOS. You’ve also learned how to create a basic “Hello, World” program with Pygame.
Now that you have Pygame installed, you’re ready to start making your own games!