Installing pygame on my Mac

I have a MacBook Air running Mountain Lion (10.9). I also have a RaspberryPi that I want to use as a digital picture frame (along with a monitor - of course).

My choice of digital picture frame software is - home brew pygame - running from the console on the RaspberryPi.

On the RPi I get pygame with a rasbian image. On the Mac I have to install it by myself. I found a fine guide on pygame.org. Here is what I did:

  • Installed python - the pure 32-bit 2.7.x from vpython.org
  • Install VPython-Mac-Py2.7-x from vpython.org (which should include numpy)
  • Installed the SDL libraries from libsdl.org. You will need base, SDL_mixer, SDL_ttf, and SDL_image.
  • Installed the libjpeg and libpng libraries precompiled from ethan.tira-thompson.com
  • Installed Xcode from Apple apps.
  • Added command line tools. To do this start Xcode and go to Preferences under Xcode menu. Choose the Download tab and select Components and install.
  • Installed XQuartz as Mountain Lion OS X no longer includes the X11 window system library. Find it on xquartz.macosforge.org
  • Downloaded pygame tar file from http://pygame.org/download.shtml Decompressed and extracted to create directory pygame1.9.1release
  • Before compilation of pygame: ** SDL_x header files refer to SDL as <SDL/SDL_yy.h>; However, a SDL directory is not under the include directory of SDL (SDL/Headers). To fix this in a simple way: I Went to directory /Library/Frameworks/SDL.framework/Headers ** then made a link as follows: ln -s SDL ./
  • Changed to the pygame directory (normally pygame1.9.1release). Then switched to the super user. However, you can use the sudo command instead. I set the following compilation flags export CC='/usr/bin/gcc' export CFLAGS='-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -I/opt/X11/include -arch i386' export LDFLAGS='-arch i386' export ARCHFLAGS='-arch i386' You must specify using the original location of X11. The mac does not have a ld.so.conf and apparently the links generated by XQuartz in /usr do not work correctly.
  • Now execute: python config.py This should find the SDL, jpeg, png, and numpy librariespython setup.py build This will build in the directory before installing. It should complete with no errors. then python setup.py install
  • Confirmed that it worked: Out of super user mode and in a terminal shellpython and within python import pygame this gave no error and a simple pygame program ran fine.