Building PIL on OS X: Snow Leopard

Published on 2010-02-25 15:40:00+00:00
Mac   OS   PIL   Python   X   homebrew   virtualenv  

There are several places online that discuss problems installing PIL on Mac OS X Snow Leopard

This is how I got it to work.

  1. Install lib jpeg using homebrew (which is super-aweseome!)
brew intall jpeg

.This installs the library into

  1. Install libfreetype the old-fashioned way (./configure, make, sudo make install). I used freetype-2.1.10.pre-20050511.

  2. Download, unpack PIL (I used Imaging-1.1.6). I had to make the following changes to

FREETYPE_ROOT = "/usr/local"  
JPEG_ROOT = ("/usr/local/Cellar/jpeg/7/lib", "/usr/local/Cellar/jpeg/7/include")
  1. Then, build PIL:
python build_ext -i
  1. If the build works without any errors, you can run the tests:

which should yield the following: 57 tests passed.

  1. (optional) I like to use virtualenv, so I activate that:
workon myproject
  1. Install PIL:
python install

At this point, code like the following works for me:

import Image  
im ="/path/to/pretty/picture.jpg")