How to install PyObjC, pygame, and gasp on Mac OS X for Python tutorial

I am going through the Python tutorial “How to Think Like a Computer Scientist” right now, and it is an excellent source for beginner/intermediate Python hands-on learning.

http://openbookproject.net/thinkCSpy/

However, when I got to chapter 8, my fun stopped right away. The author refers to a Python library called GASP (Graphics API for Students of Python) and gives an example and case study of a small game. The thing is, he doesn’t tell you how to install the module and it abruptly interrupts your lovely Python learning experience.

http://openbookproject.net/thinkCSpy/ch08.xhtml

I tried to use easy_install to install most of these, and it always ended up failing for some reason or another.

As I am using Mac OS X Leopard, I will provide the missing instructions for how to get the gasp module installed (and its dependencies) for anyone else who runs into this situation:

How to install PyObjC, pygame, and gasp on Mac OS X

  1. I assume that you have already installed some version of Python; I am using Universal Python 2.5 from http://www.pythonmac.org/packages/ which is a nice, easy-to-install package and has other prebuilt packages like numpy, wxPython, matplotlib, etc. ready to be installed. You can see other ways to get Python on your Mac at http://wiki.python.org/moin/MacPython/PythonDistributionsForMac
  2. You will need to install PyObjC, which is also available as a package from http://www.pythonmac.org/packages/ under the 2.5 link.
  3. Now, you will install pygame from a package (pygame-1.8.0rc4-py2.5-macosx10.4.mpkg.zip) available at http://rene.f0o.com/~rene/stuff/macosx/. This is linked from http://www.pygame.org/download.shtml
  4. Finally, we get to the part of installing gasp, which is confusing to find in itself. The FAQ page is at https://answers.launchpad.net/gasp-code/+faq/42 but the link to download is wrong. Get it from https://launchpad.net/gasp-code/+download. You will want to download the Code Release which is currently called python-gasp-0.1.1.tar.bz2.
  5. Extract the bz2 file and there will be a folder inside called gasp. Copy this folder to the /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/ directory and you will be in business!

    This is the command that I used: sudo cp -R ~/Desktop/python-gasp-0.1.1/gasp/ /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/gasp

  6. Open a python session and type import pygame and import gasp to make sure that they are installed correctly.
  7. Carry on with the great tutorial linked above!

I found it odd that the beginners tutorial left out all of this information. Hopefully this will save someone the two days that it took me to find all of these links, packages, and methods.

Posted in Computing, Productivity, Programming, Python