tags:

views:

731

answers:

2

I cannot use PIL because it cannot find my libjpeg!

First, I installed PIL default. And when I ran the selftest.py, 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 setup.py to

JPEG_ROOT = "/usr/lib"

Because when I "locate libjpeg", this is what I get:

locate libjpeg /usr/lib/libjpeg.so.62 /usr/lib/libjpeg.so.62.0.0 /usr/lib64/libjpeg.so.62 /usr/lib64/libjpeg.so.62.0.0 /usr/share/doc/libjpeg-6b /usr/share/doc/libjpeg-6b/README /usr/share/doc/libjpeg-6b/usage.doc /var/cache/yum/base/packages/libjpeg-6b-37.i386.rpm /var/cache/yum/base/packages/libjpeg-6b-37.x86_64.rpm

So, I ran "setup.py install" again...and did selftest.py. And I still get the same error!

Please help. thank you

+1  A: 

You need the libjpeg headers as well, not only the library itself. Those packages are typically called something ending in headers or dev, depending on what distribution you have.

Lennart Regebro
Thanks.How do I get the headers? I have CentOS distribution.I did "locate libjpeg" and couldn't find anything ending in .headers
TIMEX
They seem to be called libjpeg-devel on CentOS.
Lennart Regebro
Use the ‘package management tool’ to install `libjpeg-devel`. Note there may be other `-devel` packages you need to install for other formats, eg. `libpng-devel`.
bobince
I think PIL uses zlib for PNG, if I remember correctly. But I could misremember. It has docs though. :)
Lennart Regebro
+3  A: 

There at least 3 header sets that you will want to install. 1 more if you want to deal with Tiff's

freetype, libjpeg, zlib all of which will be in the following packages on CentOS:

== 32 Bit: zlib-devel.i386 libjpeg-devel.i386 freetype-devel.i386

== 64 Bit: zlib-devel.x86_64 libjpeg-devel.x86_64 freetype-devel.x86_64

As you did before you will want to edit the following variables in the setup.py file:

FREETYPE_ROOT JPEG_ROOT ZLIB_ROOT

Setting there values to /usr/lib or /usr/lib64 based on your platform. Once done you will most likely want to run

python setup.py build --force
python setup.py install

That will force rebuild all your lib for PIL and reinstall them raw.

NerdyNick