Freetype, jpeg, zlib and the Python Imaging Library on OSX 10.5

I've spent the better part of a few days going through the online Django book, following along closely, and executing their code examples as I proceeded.

Predictably, things haven't been smooth.

The biggest obstacle appeared when I hit Chapter 5: Interacting with Database Models. The book laid out a few sample models, and after making sure the database was set up, I was asked to run the following code from my django project folder:

The result of which was:

PIL

OK, so I head over and snag the PIL lib & attempt to set it up:

note: OSX 10.5 doesn’t come with the libraries that are necessary for the build process. Before proceeding, you’ll probably want to obtain Apple’s Xcode package and install it. (download and install Xcode 3.0) *Another note*: You’ll also want to have enabled your OSX root account (You can read how to do that here)

Oh. That's no good. An imaging library without imaging or type support. Useful.

Luckily, we're not invalids, and the PIL README yielded resources for obtaining the required libs. We need to install them and take note of their lib paths.

Freetype

If all went well, *your Freetype lib* should be installed at */usr/local/lib*.

Jpeg

If all goes well, *your Jpeg lib* can be found *in your jpeg-6b directory* (to find the path type pwd while in the jpeg-6b directory).

zlib / PNG support

Again, if all is well, *your zlib lib* can be found *in your zlib directory* (and again, type pwd while in the zlib directory to find the path)

Edit PIL's setup.py

Head back over to your PIL directory & open up setup.py in a text editor. Around line 37 you should see a set of vars ending in _ROOT, like so:

Change None to the appropriate paths, like so:

Nailed. Save setup.py and get back to the shell.

PIL, again

Let's try that install again:

*Support OK*, eh? Sounds good to me.

Success! Let's try validating our models again. Get back over to your Djando project folder, and execute the validation command again:

Yay.

If you enjoyed this post, then tweet about it!