Fixing – PIL IOError: decoder jpeg not available

So you get PIL (the Python Imaging Library) all installed on your new system and you’re feeling proud of yourself. But then you go to do some tasks involving JPEG’s and you get this horriffic error:

IOError: decoder jpeg not available

Here’s how I re-installed PIL correctly. But before you try to reinstall it, make sure you’ve removed every ounce of PIL from your system. Somehow the reinstall didn’t work until I removed both the PIL site-packages install AND the temporary installation folder i.e., where the tar file unpacked to.

My sucessful re-installation of PIL on Ubuntu 7.04:

First remove your last install!
$ sudo rm -rf /usr/lib/python2.5/site-packages/PIL
$ sudo rm /usr/lib/python2.5/site-packages/PIL.pth
$ sudo rm ~/Imaging-1.1.6

Make sure you install at the libraries for both JPEG support and FreeType2:
$ sudo aptitude install libjpeg libjpeg-dev
$ sudo aptitude install libfreetype6 libfreetype6-dev

Get PIL again and do the install:
$ wget
$ gunzip Imaging-1.1.6.tar.gz
$ tar xvf Imaging-1.1.6.tar
$ cd Imaging-1.1.6/
$ python build_ext -i

Run the included test to make sure everything now works:
$ python

If everything worked do the real install:
$ sudo python install

If my instructions still don’t help you, in your downloaded PIL archive you can also take a look at the included README file and read the comments in the included file for more setup instructions.

2 Responses to “Fixing – PIL IOError: decoder jpeg not available”

  1. Obioma says:

    Thanks, your recipe came right in time when I experienced the same issues.

  2. adnan says:

    worked for me.

    definitely need freetype, gave me ImportError for _imagingft without it.

    had to:

    sudo yum install libjpeg-devel
    sudo yum install freetype-devel