Django and Python Imaging Library (PIL) on Leopard

— Paul Annesley, November 2007

Chapter 5 of the excellent Django Book makes use of django.db.models.URLField().

When running under the default Python 2.5 environment shipped with Mac OS 10.5 Leopard, this causes an error something along these lines:

$ ./manage.py validate
Error: One or more models did not validate:
books.author: "headshot": To use ImageFields, you need to install the Python Imaging Library. Get it at http://www.pythonware.com/products/pil/ .

Assuming you’ve installed XCode (go on, you know you want to..) this can be solved like so:

Install libjpeg

wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
./configure
make
sudo make install-lib

Install Python Imaging Library (PIL)

wget http://effbot.org/media/downloads/Imaging-1.1.6.tar.gz
tar zxvf Imaging-1.1.6.tar.gz 
cd Imaging-1.1.6
sudo python setup.py install

Not too hard, but still, sucks to be us Apple users sometimes. If my Ubuntu Server virtual machine didn’t make my laptop run so damn hot, I’d be using that. Are tickless kernels and PowerTOP helping anyone on this front yet?

If it all looks too hard, I’m sure MacPorts (or is it DarwinPorts? who knows) will hold your hand.

← index