thescreamingdrills
thescreamingdrills

Reputation: 81

Python with PIL and Libjpeg on Leopard

I'm having trouble getting pictures supported with PIL - it throws me this:

IOError: decoder jpeg not available

I installed PIL from binary, not realizing I needed libjpeg.

I installed libjpeg and freetype2 through fink.

I tried to reinstall PIL using instructions from http://timhatch.com/ (bottom of the page)

But I'm still getting the same error.

I'm on Leopard PPC.

Upvotes: 3

Views: 3208

Answers (5)

Walty Yeung
Walty Yeung

Reputation: 3562

I have stuck to this problem for quite a few hours today. And my advice is do NOT do trial and error again and again, unless u could fix the problem in first 15 minutes.

there are a few tools for you to diagnose the problem:

1.check the if jpeg lib architcture matches your machine architecture:

file /usr/local/lib/libjpeg.7.dylib 

2.check if the _imaging.so acutally linked to your compiled jpeg lib

cd ImageSrc

python setup.py build_ext -i

otool -L PIL/_imaging.so 

3.try to import _imaging.so and see what's the problem

cd PIL

python

import _imaging

4.finally, try to remove all previous installed PIL* from python "site-package" directory to make sure set up does work

python setup.py install

For me, it's due to I am using 32 bit python on snow leopard, and solved the problem by install jpeg lib in this way:

./configure CFLAGS="-arch i386" --enable-shared --enable-static

Upvotes: 0

Tim Hatch
Tim Hatch

Reputation: 142

If you build with libjpeg, but selftest fails, you probably have another install of PIL that's confusing things. Try installing it, and see if selftest works then.

Also the direct link to the instructions referenced in the OP is here

Upvotes: 0

William Knight
William Knight

Reputation: 700

I had the same problem and this guy's post provided the solution for me:

rm the PIL subdir and the PIL.pth file in the Imaging-1.1.6 subdir

full details here:

http://blog.tlensing.org/2008/12/04/kill-pil-%E2%80%93-the-python-imaging-library-headache/

After doing this, the selftest.py worked fine. I should also note that I am using the macports version of the jpeg library and I had already specified the JPEG_ROOT to point to the include and lib paths in my macports root

Upvotes: 1

ayaz
ayaz

Reputation: 10502

I had the similar 'jpeg decoder problem' recently when deploying a django project on a product RHEL box that required PIL. I downloaded PIL, and ran 'python setup.py install' instantly, and was happy that everything was working, until I bumped into the problem. Solution: libjpeg was already installed on the system, so I installed libjpeg-devel. I went back into the source of PIL and ran 'python setup.py build', at the end of which, in the output where it shows whether PIL configure was able to detect support for jpeg, gif, freetype, etc, it said that jpeg support was ok. After installing PIL, it worked fine.

Upvotes: 1

Doug Miller
Doug Miller

Reputation: 1346

Is the python path still looking at the old binary version of libjpeg?

You will need to modify it to point to the new place if it is.

When you compiled the new version of the PIL did it say that it found libjpeg? It will compile happily without it (iirc) and the first sign of trouble you will see is at include time.

You will need to adjust the path at ./configure time.

The diff might just not work for you. You should test some more and then perhaps file a bug.

Upvotes: 0

Related Questions