Ben Crowder

Blog: #homebrew

1 posts :: tag feed :: about the blog :: archive

Installing PIL on Lion

Getting PIL working on Lion was a little more difficult than I thought it’d be. (I use PIL in Ink to resize images.) It appeared to install correctly, but when I tried to post something with an image, I got this:

ImportError: The _imaging C module is not installed

I followed the instructions at, but libjpeg wouldn’t compile, giving me this error:

checking build system type... mkdir: /private/tmp/PKInstallSandbox.vMj5ds/tmp: No such file or directory
mkdir: /private/tmp/PKInstallSandbox.vMj5ds/tmp: No such file or directory
config.guess: cannot create a temporary directory in /private/tmp/PKInstallSandbox.vMj5ds/tmp
configure: error: cannot guess build type; you must specify one

Turns out TotalTerminal had oddly set $TMPDIR to /private/tmp/PKInstallSandbox.vMj5ds/tmp, which obviously broke other things. I cleared it out (export TMPDIR=) and got libjpeg to compile.

But PIL still gave me this error when I tried to import _imaging in Python to test it:

ImportError: dlopen(/Library/Python/2.7/site-packages/PIL/, 2): Symbol not found: _jpeg_resync_to_restart
  Referenced from: /Library/Python/2.7/site-packages/PIL/
  Expected in: flat namespace

Oh joy. When I ran otool -L /Library/Python/2.7/site-packages/PIL/, libjpeg didn’t show up in the list, either. I recompiled and reinstalled libjpeg and PIL a few more times. No luck.

The final solution: I installed libjpeg via Homebrew (brew install libjpeg), then compiled and installed PIL (Imaging 1.1.7). That fixed the problem and PIL now works like a charm.

Reply via email or via office hours