resopollution
resopollution

Reputation: 20350

Snow Leopard Python 2.6 problems getting PIL to work

I installed libjpeg and PIL, but when I try to save a JPG image, I always get this error:

ImportError: The _imaging C module is not installed

Any help much appreciated!

I tried to import _imaging w/ Python interpreter to see what's wrong and got this:

    >>> import _imaging
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so, 2): Symbol not found: _jpeg_resync_to_restart
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so
  Expected in: dynamic lookup

Upvotes: 2

Views: 5052

Answers (4)

shacker
shacker

Reputation: 15371

A lot of these errors happen when compiling from source when you've previously installed python tools from fink or ports. For example the _jpeg_resync_to_restart error can happen when you've got leftover libjpeg files in /opt/local/lib. Try this:

cd /opt/local/lib
sudo rm *jpeg*

Then recompile libjpeg (starting with make clean), then recompile PIL (starting with rm -Rf build).

After that, import _imaging should work. Did for me anyway.

Upvotes: 4

Tim Hatch
Tim Hatch

Reputation: 142

I just hit this as well on SL, and the problem is likely your libjpeg was built without a matching architecture. Assuming you're using MacPorts, run file /opt/local/lib/libjpeg.dylib. The right way is to build everything with MacPorts as +universal, see Universal Binaries in MacPorts as it relates to PIL dependencies.

Upvotes: 4

Bram Braakman
Bram Braakman

Reputation: 11

I kept having this problem as well. It turned out to be related to a change I made to my .bash_profile (forcing the usage of ggc-4.0) when trying to fix a MySQLdb installation problem.

http://www.brambraakman.com/blog/comments/installing_pil_in_snow_leopard_jpeg_resync_to_restart_error/

Upvotes: 1

Lennart Regebro
Lennart Regebro

Reputation: 172309

Edit: Thanks for the added error message. This is apparently a problem with the jpeglib on Snow Leopard. Have you tried this?

http://jetfar.com/libjpeg-and-python-imaging-pil-on-snow-leopard/

Upvotes: 2

Related Questions