P16: a blog by Matt Kangas home archive
31 May 2008

AppEngine: Installing PIL on OS X 10.5.3

The just-released 1.1.0 API for Google App Engine contains a new "Imaging" library. Hooray! It works by providing stubs, which use Python Imaging Library (PIL) in development, and some-other-machine-behind-the-curtain when you deploy to Google.

So, if you're developing for App Engine, you now need PIL on your development system too. Google provides a Installing PIL document. Unfortunately, their directions re: OS X are not quite right:

Alas, that package will refuse to install if you are using the original Python interpreter that ships with Mac OS X.

After hitting this obstacle and wasting a half hour digging through obsolete HOWTOs, I found this nugget in the pythonmac.org Leopard page:

4. In Terminal, create a symbolic link for the system's Python.framework in the location expected by the pythonmac.org tools, like so:

cd /Library/Frameworks
sudo ln -s /System/Library/Frameworks/Python.framework/ Python.framework

Yes, you can skip steps 1-3 and jump directly to 4 if you just want to PIL, not IDLE or anything else. Now run the PIL installer. It should work!

You also need to add the PIL install location to PYTHONPATH. Stick the following in ~/.bashrc.

export PYTHONPATH=/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/

Now open a new terminal window, and type:

python -c "from PIL import Image"

If you don't see an error message, you're done. :)