views:

1450

answers:

4

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)

"* Download PIL 1.1.6 source package and have the Developer Tools already installed * Patch setup.py with this patch so it can find the Freetype you already have. (patch -p0 < leopard_freetype2.diff) * sudo apt-get install libjpeg if you have fink (otherwise, build by hand and adjust paths)"

But I'm still getting the same error.

I'm on Leopard PPC.

A: 

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.

Hyposaurus
+1  A: 

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.

ayaz
Nice tip - I think I'm getting closer. I ran python setup.py build, and saw that I had Tkinter, JPEG, ZLIB, and FREETYPE2 - all ok. But then I ran python selftest.py, and it returned the same message IOError: decoder not available. Looks like I've got my night planned now.
thescreamingdrills
+1  A: 

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

William Knight
A: 

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

Tim Hatch