Last modified 5 years ago Last modified on 07/22/2012 04:46:46 PM

PyGame Notes

This is a place to collect some notes about PyGame:

Installation on Mac OX 10.6

These instructions refer to PyGame 1.9.2pre from the mercurial repo on bitbucket as of 2/2012.

Via MacPorts

Assuming Python 2.7 is already installed also via MacPorts, i.e. it is available as /opt/local/bin/python2.7.

I also installed virtualenv and virtualenvwrapper for the MacPorts Python version and renamed the virtualenvwrapper shellscript to /usr/local/bin/ so I could use it alongside the virtualenvwrapper version I installed for the Mac OS X system Python installation.

$ sudo port install mercurial libsdl libsdl_image libsdl_mixer libsdl_ttf smpeg portmidi py27-pip
# go drink some coffee...
$ source /usr/local/bin/
$ mkvirtualenv -p python2.7 pygame
(pygame)$ pip-2.7 install hg+

If your installation from above is missing some libraries, i.e. you get errors when trying to pygame.image.load() a PNG file, you might need to compile from your own working copy and apply this patch to the configure script. This fixes the name of the "CoreMIDI" framework in the dependencies (not "CoreMidi"), and adds some locations to look for SDL header files.

Note: this patch (in slightly modified form) was already applied to the PyGame repository as of 2012-03-03.

hg clone
cd pygame
patch -p0 </path/to/config_darwin.diff
python -setuptools install

The -setuptools option is important, otherwise setup will (try to) install header files as root into the virtualenv and then fail later.

Note: Libraries scrap, avcodec und swscale seem not to be present in MacPorts, so support for them will not be compiled into pygame.

Via homebrew


Installation on Ubuntu

Ubuntu 11.10 (Oneiric) or 12.04 LTS (Precise):

Install Python, mercurial, python-setuptools or distribute, pip, virtualenv and virtualenvwrapper (pip and distribute can also be installed in the virtualenv only).

$ sudo apt-get build-dep python-pygame
$ mkvirtualenv pygame
(pygame)$ hg clone
(pygame)$ cd pygame
# apply local patches
(pygame)$ ORIGLIBDIRS="/lib:/lib/`uname -i`-linux-gnu:/lib64:/X11R6/lib" \
    python [-setuptools] install

Note: the PyGame package is just called pygame on Ubuntu 12.04, but specifying python-pygame will still work.

Again, you'll probably need the -setuptools option when installing into a virtualenv.


pexdra (PyGame Extended Drawing)
a module for drawing anti-aliased circles, circle segments and rectangles. Pure Python.

My modified copy of pexdra.

General Libraries

Game objects
a collection of 2D and 3D maths classes, and algorithms for helping in the creation of games with Python/PyGame. From the author of the book Beginning Game Development with Python and PyGame
FilenameSizeUploaded byOnNotes
config_darwin.diff 2.9 KB carndt 6 years ago Pygame OS X configuration script fixes