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 (bottom of the page)

  • Download PIL 1.1.6 source package and have the Developer Tools already installed
  • Patch 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.

Asked by: Aida720 | Posted: 01-10-2021

Answer 1

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 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 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.

Answered by: Ned611 | Posted: 02-11-2021

Answer 2

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:

After doing this, the 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

Answered by: Maddie588 | Posted: 02-11-2021

Answer 3

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.

Answered by: Luke713 | Posted: 02-11-2021

Answer 4

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

Answered by: Charlie959 | Posted: 02-11-2021

Answer 5

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 acutally linked to your compiled jpeg lib

cd ImageSrc

python build_ext -i

otool -L PIL/ 

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

cd PIL


import _imaging

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

python 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

Answered by: Kevin443 | Posted: 02-11-2021

Similar questions

Python PIL cannot locate my "libjpeg"

I cannot use PIL because it cannot find my libjpeg! First, I installed PIL default. And when I ran the, it gave me: IOError: decoder jpeg not available 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. Then, I followed instructions online to change PIL's to J...

python - Tell sage where to find libjpeg

I have installed Sage on Mac OS X. It looks like it has PIL. The following code gives me an IOError.. import Image a ="pic.jpg") a.thumbnail((int(100), int(100))) This is the error I get. IOError Traceback (most recent call last) &lt;ipython console&gt; in &lt;module&gt;() /sage...

Canopy Python import PIL libjpeg not found

I am facing a problem with Canopy python and the Python Image Library. I would like to use the _imaging library, but importing yields a libjpeg not found error import _imaging dlopen("/home/abcd/Canopy/C64/User/lib/python2.7/site-packages/PIL/", 2); Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; ImportError: cannot open shared object fil...

python - Find which libjpeg is being used by PIL / PILLOW WINDOWS

I want to know which version of libjpeg is used with my version of Pillow 9.1.1 since converting the pillow image to numpy array and reading it with cv2 give me different results. The images look the same but have different values for certain pixels, and I already considered the fact that cv2 reads as BGR instead of RGB. But even after the color conversion the images continue to be different. Similar situation to this ques...

Still can't find your answer? Check out these communities...

PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python