views:

2198

answers:

5

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
+2  A: 

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/

Lennart Regebro
I followed this link to the dot and I still get this error :( - it seems whatever I try I can't get this to work, tried several sources on google already.
resopollution
I've also installed libjpeg7, libjpeg6 (I have not uninstalled any version - maybe this is why?).
resopollution
How did you install these libraries and to what location? Chances are that location is not in the dynamic load search path. Try running otool -L /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so
Ned Deily
@resopollution: OK, I don't have Snow Leopard, so I'm no more help now. :)
Lennart Regebro
Perhaps you have to reinstall PIL after having installed libjpeg. I'm running python and PIL on snow leopard without any problems. I installed libjpeg7 first for something else (libgd I think).
Markus
Oh, absolutely, you need to recompile it even, so you must remove the build directory under the PIL source and do a reinstall. The build process will not notice that the library has been updated, AFAIK.
Lennart Regebro
Tried everything , still no go :(
resopollution
same error everytime about "Symbol not found: _jpeg_resync_to_restart" seems other people have the problem, but no solution
resopollution
+1  A: 

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%5Fpil%5Fin%5Fsnow%5Fleopard%5Fjpeg%5Fresync%5Fto%5Frestart%5Ferror/

Bram Braakman
+4  A: 

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.

Tim Hatch
thanks, I think you are right, i will check it out and verify
resopollution
+2  A: 

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.

shacker
A: 

Thanks

Managed to sort out my issue by using Shackers steps.

However tried this on my server.

all the import statements work flawlessly.

import PIL
import Image
import _imaging
i = Image.open("/path/to/file/file.jpeg")
i.save("/path/to/file/other_filename.jpeg")

works fine, however Now this in my django on the server I still get an error.

c _imaging not installed

Any ideas why?

ApPeL