I have PIL installed via pip. I have libjpeg installed via homebrew. I have the system python.

I was having problems with PIL’s jpeg module. It was giving the error message: “ImportError: The _imaging C module is not installed”. It was installed, but it was broken. Telling python to import _imaging gave me the better message: “Symbol not found: _jpeg_resync_to_restart”.

So I had a look: dyldinfo -dylibs /Library/Python/2.7/site-packages/PIL/_imaging.so and saw this:

for arch i386:
attributes     dependent dylibs
                /usr/lib/libz.1.dylib
                /usr/lib/libSystem.B.dylib
for arch x86_64:
attributes     dependent dylibs
                /usr/local/lib/libjpeg.8.dylib
                /usr/lib/libz.1.dylib
                /usr/lib/libSystem.B.dylib

So the i386 architecture has no libjpeg. Fix thusly:

  • sudo pip uninstall PIL
  • brew remove jpeg
  • brew install --universal jpeg # NOTE the “–universal” flag
  • sudo pip install PIL

Afterward, if you run dyldinfo -dylibs /Library/Python/2.7/site-packages/PIL/_imaging.so you’ll see:

for arch i386:
attributes     dependent dylibs
                /usr/local/lib/libjpeg.8.dylib
                /usr/lib/libz.1.dylib
                /usr/lib/libSystem.B.dylib
for arch x86_64:
attributes     dependent dylibs
                /usr/local/lib/libjpeg.8.dylib
                /usr/lib/libz.1.dylib
                /usr/lib/libSystem.B.dylib