0 votes
1 view
in Python by (32.3k points)

PIL does support JPEG in my system.

Whenever I do an upload, my code is failing with:

File "PIL/Image.py", line 375, in _getdecoder

    raise IOError("decoder %s not available" % decoder_name)

IOError: decoder jpeg not available

How do I resolve it?

1 Answer

0 votes
by (16.8k points)

libjpeg-dev is required to be able to libjpeg-dev is required to be able to process jpegs with pillow (or PIL), so you need to install it and then recompile pillow. It also seems that libjpeg8-dev is needed on Ubuntu 14.04

If you're still using PIL then you should really be using pillow these days though, so first pip uninstall PIL before following these instructions to switch, or if you have a good reason for sticking with PIL then replace "pillow" with "PIL" in the below).

On Ubuntu:

# install libjpeg-dev with apt

sudo apt-get install libjpeg-dev

# if you're on Ubuntu 14.04, also install this

sudo apt-get install libjpeg8-dev

# reinstall pillow

pip install --no-cache-dir -I pillow

If that doesn't work, try one of the below, depending on whether you are on 64bit or 32bit Ubuntu.

For Ubuntu x64:

sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib

sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib

sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib

Or for Ubuntu 32bit:

sudo ln -s /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib/

sudo ln -s /usr/lib/i386-linux-gnu/libfreetype.so.6 /usr/lib/

sudo ln -s /usr/lib/i386-linux-gnu/libz.so /usr/lib/

Then reinstall pillow:

pip install --no-cache-dir -I pillow

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...