Django and Python Imaging Library (PIL) on Leopard
19 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.
This is the personal website of
Comments
This post has 10 comments.
04 December 2007
Paul Annesley says:
I forgot that Leopard still doesn't come with wget. It compiles and installs cleanly from source under Tiger and Leopard (./configure && make && sudo make install), or you could probably s/wget/curl -O/ in the instructions above.
10 December 2007
Jamie Quint says:
Thanks for this, now it looks like the URL for PIL has changed to http://effbot.org/media/downloads/Imaging-1.1.6.tar.gz
11 December 2007
Paul Annesley says:
The permanent redirect they were serving from the old URL should have taken care of the change, but I've updated the post - Cheers.
06 January 2008
Gavi says:
Looks like there is an issue with libjpeg installation
sudo make install-lib
/usr/bin/install -c -m 644 jconfig.h /usr/local/include/jconfig.h
install: /usr/local/include/jconfig.h: No such file or directory
make: *** [install-headers] Error 71
14 May 2008
Michael Burton says:
Thanks for this post. My own preference is to install from packages. That being said, I had some difficulty using pypi's easy_install to install PIL.
A solution I found that worked for me is available here: http://emmby.blogspot.com/2008/05/installing-python-pil-on-mac-os-x-1052.html
23 June 2008
Nehemiah Isaiah Dacres says:
I had a few permission errors so i installed via macports however I had to stop the python installl, im not to happy about installing an entire other python version. Is there a way to install it from the macports distro? like, draging /opt/local/pil into /usr/local/pil ?
03 July 2008
Byron Ruth says:
Nice and simple. I enjoy finding guides that don't use all those pre-compiled macports and darwinports packages. Sometimes it is just easier to build from source.
17 August 2008
Luke says:
I am having the same problem as Gavi:
sudo make install-lib
/usr/bin/install -c -m 644 jconfig.h /usr/local/include/jconfig.h
install: /usr/local/include/jconfig.h: No such file or directory
make: *** [install-headers] Error 71
28 August 2008
Winston says:
Luke and Gavi-I had the same problem. You need to create the /usr/local/man folder. Try these commands:
sudo mkdir /usr/local/man
sudo mkdir /usr/local/man/man1
20 September 2008
Paul Annesley says:
Alas, comments are closed due to spammers that are getting past Akismet filtering.
Thanks everyone for chiming in.