JPEG decoder not available in PIL

P

Peter

I have a problem which seems to come up from time to time but I can't
find anything relevant in the archives. I have used PIL v1.1.5 with no
problem on Windows for some time but now wish to put it on Linux (Suse
Linux v10.0). I obtained and built the JPEG libraries (jpeg-6b) without
any problem. The tests for the installation work fine. I built Python
2.4.2 from the sources but with no special options, just 'out of the
box'. This works fine. PIL built as it should but the selftest.py fails
with the ‘'decoder jpeg is not available'’ message (the other 54
tests are OK). Other images are opened and shown with xv, no problem. I
think that there is something wrong with the libraries or the way they
linked. ....

At the last moment I managed to solve this problem and I hope it is
worth supplying the details here. First there is a file in the install
directory libImaging/Jpeg.h which has a line:

#include "jpeglib.h"

but there is no such header file. On my system I put:

#include "/usr/local/include/jpeglib.h"

which is where the JPEG installation put the include files for the
library. With this change all 55 tests passed successfully. Then I
copied the PIL library from the installation directory where it was
built to the Python site-packages location. And then everything worked.
For some reason it was not enough to do python setup.py install but
this is probably an artifact of previous failures.

Hope this helps someone ...

Peter
 
H

Heiko Wundram

Peter said:
At the last moment I managed to solve this problem and I hope it is
worth supplying the details here. First there is a file in the install
directory libImaging/Jpeg.h which has a line:

#include "jpeglib.h"

but there is no such header file. On my system I put:

#include "/usr/local/include/jpeglib.h"

which is where the JPEG installation put the include files for the
library. With this change all 55 tests passed successfully.

This is baaaaad! You're mixing two libraries here, for one the system jpeg
library and for another your library. Probably the dynamic loader cache
finds the system library first, so although you included the specifications
for the library you installed to /usr/local, you link against the system
library which might be different (in this case it is not and for jpeglib
will never be, but nevertheless, this is an absolute NONO).

PIL comes precompiled for SuSE, btw., and the package is called Imaging,
IIRC (long time since I've tried SuSE).

Next time round you want to install something, read up on the distinction
between <pkg> and <pkg>-devel. The former contains only the files necessary
at runtime (thus, no static libraries, no headers, etc.), while the latter
contains everything the package installs that isn't in the former. Thus, to
install PIL you should have done:

rpm -Uvv libjpeg-devel-<something>.rpm

or installed

libjpeg-devel

using the SuSE package manager. Then the PIL intallation would have found
the appropriate header files and compiled successfully. Actually, you must
have installed python-devel for the installation package to succeed. Or did
you build Python yourself and overwrote the standard python that was
installed? If so, really do read up on package management using RPM,
there's quite a lot on this on SuSE's site. Otherwise you'll wreck your
system in the longrun...

--- Heiko.
 
F

Fredrik Lundh

:

At the last moment I managed to solve this problem and I hope it is
worth supplying the details here. First there is a file in the install
directory libImaging/Jpeg.h which has a line:

#include "jpeglib.h"

but there is no such header file. On my system I put:

#include "/usr/local/include/jpeglib.h"

which is where the JPEG installation put the include files for the
library.

note that the setup file does in fact pass in /usr/local/include via the
compiler's -I option, so if the above fix made things work, your compiler
setup is pretty weird...

or maybe you have conflicting versions of libjpeg installed in different
locations? (but I don't think there has ever been conflicting releases
of libjpeg, so that doesn't seem likely...)

</F>
 
P

Paul Dickson

I have a problem which seems to come up from time to time but I can't
find anything relevant in the archives. I have used PIL v1.1.5 with no
problem on Windows for some time but now wish to put it on Linux (Suse
Linux v10.0). I obtained and built the JPEG libraries (jpeg-6b) without
any problem. The tests for the installation work fine. I built Python
2.4.2 from the sources but with no special options, just 'out of the
box'. This works fine. PIL built as it should but the selftest.py fails
with the ‘'decoder jpeg is not available'’ message (the other 54
tests are OK). Other images are opened and shown with xv, no problem. I
think that there is something wrong with the libraries or the way they
linked. ....

It seems you did not build the RPMs for the JPEG libraries, so the
include files were not placed in the correct location:

# rpm -ql libjpeg-devel
...
/usr/include/jpeglib.h
...

Perhaps you should try "yum install libjpeg libjpeg-devel" if Suse
supports yum.

-Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top