56

I tried to use PIL to do some JPEG work in my django app with PIL but I'm getting this IOError.. not sure what to do.

""decoder jpeg not available""

Am I missing the JPEG decoder from my server? If so, how do I fix it?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Brian D
  • 9,863
  • 18
  • 61
  • 96
  • I found this post and it really helps me : http://obroll.com/install-python-pil-python-image-library-on-ubuntu-11-10-oneiric/ – kschaeffler Sep 12 '12 at 16:45
  • possible duplicate of [Python Image Library fails with message "decoder JPEG not available PIL"](http://stackoverflow.com/questions/8915296/python-image-library-fails-with-message-decoder-jpeg-not-available-pil) – neves Oct 09 '13 at 23:52

8 Answers8

73

I have found this answer from author "edward"

On Ubuntu precise, PIL doesn't find the jpeg library files, even once they are installed. The easiest way to fix this is to make a symlink after you have installed the jpeg dev package. So, I needed an extra step:

for x64 OS

pip uninstall PIL
sudo apt-get install libjpeg8-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
pip install PIL

for x32 OS

pip uninstall PIL
sudo apt-get install libjpeg8-dev
sudo ln -s /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib
pip install PIL

I confirm that this is working for me on Ubuntu Linux 12.04.


If you are a Mac user - you need to install Xcode and Command Line Tools. Read how to do this

Anton Danilchenko
  • 2,318
  • 1
  • 25
  • 24
60

You need to install jpeg library first and reinstall your PIL. For example, I'm using CentOS, to install libjpeg, I run

sudo yum install -y libjpeg-devel

It depends on what kind of linux you are using. And here you have to remove the old PIL

rm -rf /usr/lib/python2.6/site-packages/PIL-1.1.7-py2.6-linux-x86_64.egg/

Then install the PIL

sudo easy_install PIL
Fang-Pen Lin
  • 13,420
  • 15
  • 66
  • 96
20

A stronger answer can be found at install pil on virtualenv with libjpeg

For me what finally worked on Ubutu was:

pip uninstall PIL
sudo apt-get install libjpeg8-dev
pip install PIL

The Python Imaging Library (PIL) seems really picky about version and location of the jpeg libraries. And because PIL is written in C and compiled, you need the development versions of the library in addition to the runtime versions.

Community
  • 1
  • 1
Bryce
  • 8,313
  • 6
  • 55
  • 73
  • At Ubuntu 12.04.2 LTS using Pillow `pip uninstall Pillow` `sudo apt-get install libjpeg8-dev` `pip install Pillow` works for me – Moreno Oct 29 '14 at 20:57
6

I don't have sudo privileges, because I am on a shared bluehost server. So I can't run any of those sudo apt-get jpeg commands. I ended up running

pip uninstall pil
pip install pillow

and apparently pillow was able to find support for jpegs.

Chase Roberts
  • 9,082
  • 13
  • 73
  • 131
4

There is a selftest.py in your Imaging installation folder, try:

python selftest.py

you will see something like that:

--------------------------------------------------------------------
*** PIL CORE support not installed
*** TKINTER support not installed
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
*** FREETYPE2 support not installed
*** LITTLECMS support not installed
--------------------------------------------------------------------

if JPEG support not available, Centos:

yum install libjpeg-devel
yum install freetype-devel 
yum install libpng-devel
hahakubile
  • 6,978
  • 4
  • 28
  • 18
3

For mac's users, You can download the library from here: http://ethan.tira-thompson.com/Mac_OS_X_Ports.html. Then, uninstall and install PIL

cmaluenda
  • 2,099
  • 1
  • 14
  • 15
0

On Debian distributions use libjpeg62-turbo-dev instead of libjpeg8-dev

Steve
  • 1,072
  • 11
  • 28
0

You can build PIL from source: http://effbot.org/zone/pil-decoder-jpeg-not-available.htm

TryPyPy
  • 6,214
  • 5
  • 35
  • 63
  • I did, but running the selftest it still tells me .. from line #24 of selftest.testimage Expected: ('JPEG', 'RGB', (128, 128)) Got: decoder jpeg not available 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. – Brian D Jan 08 '11 at 04:03
  • I'm assuming the whole ./configure --with-jpeg=/somelib/lib --with-zlib=/somelib/lib line means I need to go fetch a copt of the jpeg library – Brian D Jan 08 '11 at 04:05
  • Yes, but you can probably do that with your package manager, e.g. on Ubuntu: "apt-get install libjpeg-dev". – TryPyPy Jan 08 '11 at 04:08