Installing Pygame

Pygame runs on all systems, but setup is slightly different on each OS. The instructions here assume you’re using Python 3, and provide a minimal installation of Pygame. If these instructions don’t work for your system, see the more detailed notes at http://ehmatthes.github.io/pcc/.

Install Pygame on Linux

sudo apt-get install python3-dev mercurial libsdl-image1.2-dev libsdl2-dev libsdl-ttf2.0-dev
pip install --user hg+http://bitbucket.org/pygame/pygame

Pygame on OS X

This assumes you’ve used Homebrew to install Python 3.

brew install hg sdl sdl_image sdl_ttf
pip install --user hg+http://bitbucket.org/pygame/pygame

Pygame on Windows

Find an installer at https://bitbucket.org/pygame/pygame/downloads/ or http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame that matches your version of Python. Run the installer file if it’s a .exe or .msi file. If it’s a .whl file, use pip to install Pygame:

python –m pip install --user pygame-1.9.2a0-cp35-none-win32.whl

Testing your installation

To test your installation, open a terminal session and try to import
Pygame. If you don’t get any error messages, your installation was
successful.

$ python
import pygame

Leave a Reply

Your email address will not be published. Required fields are marked *