I was trying to get PIL to work on my ubuntu box but it failed to handle JPEGs. The system responded with the dreaded “IOError: decoder jpeg not available”. Here is what I did to solve it…
I am running my pylons project through a virtual environment. All the libraries are installed with pip, always run from within the virtual environment. When I tried to use PIL on my MAC I had no problems, but the same code just failed on Ubuntu (I was trying to generate some thumbnails from JPEGs).
The reason was that PIP was not installed properly. It required for the installation some libraries for dealing with JPEGs which it failed to find. What you have to do is tell it where to get it from. Before doing that make sure that your system has the necessary libraries. This seems to be enough for most cases:
1
| |
If this does not do it, then try all the other possible libjpeg libraries. Now follow the steps:
Step 1: Download the code of PIL with pip (or rather uninstall PIP first - pip uninstall PIL)
1
| |
This should download the source in the build directory of your environment.
1
| |
Step 2: Edit the setup.py file
Find this line:
1
| |
and change it to:
1
| |
Have a look at the setup.py in case you need to specify separately the lib and the include directory.
Step 3: Finish the installation
1
| |
If all went well then you should see at the end of the installation something like this (see the JPEG line):
1 2 3 4 5 6 7 | |