Random ramblings about Mac, Python, TeX, programming, and more  |     |          |     |  


PyGame for Python 3 on OS X Mountain Lion

May 8, 2013  |  os-x, programming, python

These are my steps to install PyGame for Python 3 on OS X Mountain lion:

  1. Download (and unpack) the following:
  2. Install the png and jpeg libraries:
    • (cd libpng-1.6.2; ./configure; make; sudo make install)
    • (cd jpeg-9; ./configure; make; sudo make install)
  3. Install XQuartz-2.7.4:
    • Run the XQuarts package installer
    • ln -s /opt/X11/include/X11 /usr/local/include/X11
  4. Install PyGame:
    • cd pygame-1.9.1release
    • Edit the src/scale_mmx64.c file: replace movsxl with movslq
    • python3 config.py
    • python3 setup.py build
    • sudo python3 setup.py install

I already had Numpy (for Python 3) and the SDL libraries installed, but you need them as well. Install them before step 1 above. In Python 3.2 and newer the PyCObject API is replaced by the PyCapsule API. The convert the PyGame code to use PyCapsule perform the following steps in the PyGame source folder (before the "python3 config.py" command in step 4 above):

A copy of the original files is kept in files with a .org extension.

Last updated: May 8, 2013