Jan
2010
Installing PIL on Mac OS X Snow Leopard for use in Google App Engine
Python users who use Django or Google App Engine on the Mac, will likely benefit from the python imaging library (PIL).
However, installing on Mac OS X (Snow Leopard) can be tricky. There are many blog posts on the issue. The most common problem is that PIL and libjpeg (a dependency) seem to install OK, but when you go to use it in your Python code, you get “_jpeg_resync_to_restart” errors.
A further complication is the fact that Google App Engine uses Python version 2.5 (and not the default 2.6 that comes with Snow Leopard). If you just need PIL for Django, you can ignore the 2.5 references (i.e. python2.5 becomes python).
Here’s how I got it working on my machine (the steps are a combination of others’ blog posts, but main credit goes to Michael Richardson’s post):
- Download libjpeg (the latest .tar.gz version): http://www.ijg.org/files/.
- Download PIL (the latest version for Python 2.5): http://www.pythonware.com/products/pil/
- Extract libjpeg and do the standard install affair:
from within the directory. The first line is the gem that many other blog posts leave out (and it assumes you’re using BASH)
export CC="gcc -arch i386"
./configure
make
sudo make install
- Extract the PIL and change in to that directory.
- [optional] libjpeg will have been installed in /usr/local/lib/, by default, above. Normally this directory will be picked up automatically by the PIL install below, but just for good measure (or if you have problems later in the PIL install), edit the
setup.py, look for the line. Change that line to
JPEG_ROOT = None
and save it.
JPEG_ROOT=libinclude( "/usr/local" )
- Install PIL by running
sudo python2.5 setup.py install
That was enough to get it running for me. I can start App Engine (I use the Google-provided launcher), and use the Image API.

Search
Categories
Links
Tags:


Read the rest of this entry