About the PIL Error -- IOError: decoder zip not available

PythonPython Imaging-Library

Python Problem Overview


I am getting the:

IOError: decoder zip not available

when I try to draw an image and save to a jpeg in PIL. Any thoughts on how to resolve this? PIL has worked fine for me in the past, when it comes to viewing/uploading images.

Python Solutions


Solution 1 - Python

sudo pip uninstall PIL
sudo pip install pillow 

^^ fixed it for me.

Pillow is a fork of PIL that is compatible with pip/setuptools and gets a little better maintenance. I haven't seen any API differences yet.

Edit: There is one notable API difference. PIL exposes Image as a top-level namespace, so you can

import Image # in PIL only

but

from PIL import Image  # in pillow or PIL
  • Thanks, Leopd!

Solution 2 - Python

The more detail installation PIL with zlib library in Ubuntu 64 bit :

http://obroll.com/install-python-pil-python-image-library-on-ubuntu-11-10-oneiric/

For the lazy (credits to @meawoppl for the apt-get):

$ sudo apt-get install libjpeg-dev zlib1g-dev

Solution 3 - Python

I encountered this problem on a 64bit ubuntu 13.04 desktop version and here is how I resolved it.

try to reinstall PIL, and pay attention to the output info after you reinstalled:

---------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version       1.1.7
platform      linux2 2.7.4 (default, Sep 26 2013, 03:20:26)
              [GCC 4.7.3]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
*** ZLIB (PNG/ZIP) support not available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------

notice that there is a line :*** ZLIB (PNG/ZIP) support not available, which means PIL have been built without ZLIB support, and I fixed it by doing this:

first you should have these packages install: libjpeg-dev libfreetype6-dev zlib1g-dev

sudo apt-get install python-dev libjpeg-dev libfreetype6-dev zlib1g-dev

# create these links, if already exists, remove it and re-link it
ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib

# reinstall PIL
pip uninstall PIL
pip install PIL

This time, there should be a line --- ZLIB (PNG/ZIP) support available in the output.

Reference: http://jj.isgeek.net/2011/09/install-pil-with-jpeg-support-on-ubuntu-oneiric-64bits/

Solution 4 - Python

It likely only needs the zip decoder to save the jpeg. I think I needed to follow these steps in OS X to preview jpegs.

It probably means you need to:

Solution 5 - Python

I encountered same problem. It seems to me that Pillow and pillow (different case in 'p') are two different packages. So, if you are using Pillow, pip install pillow might not help. Here is my solution:

$ pip uninstall Pillow
$ sudo apt-get install libjpeg-dev zlib1g-dev
$ pip install -I Pillow

First two lines are to remove any pillow or Pillow package.

Third line is to install the two required packages.

Forth is re-install Pillow.

Note, if you are using virtualenv, pip install/uninstall must be run under virtualenv

Solution 6 - Python

The way I fixed this on OS X Mavericks was by doing this:

Install brew:

http://brew.sh/

Install pip:

http://www.pip-installer.org/en/latest/installing.html

With those in place, you can do this:

sudo brew install lzlib     # installs zlib
pip uninstall PIL
pip install --no-index -f http://dist.plone.org/thirdparty/ -U PIL

After that, it was working fine. For an explanation of the third line, check this answer:

https://stackoverflow.com/a/2486396/290072

Solution 7 - Python

on mac

sudo brew install lzlib     # installs zlib
pip uninstall PIL
pip install PIL

Solution 8 - Python

I use 64bit ubuntu 14.04LTS desktop version, and I tried Johnny Zhao's answer.
When

exec sudo easy_install PIL

I got an error:

can't find freetype/fterrors.h

and I find freetype2 in /usr/include/

You could solve it by:

sudo ln -s /usr/include/freetype2 /usr/include/freetype

then install will be success

Solution 9 - Python

The cause may be you've installed Pillow without zlib support.

On CentOS 7:

yum install zlib zlib-devel
pip install Pillow --upgrade

And if you are using for a webapp restart your webserver to apply.

Solution 10 - Python

on my case, i just remore python-image, make sure that libz is ready then reinstall PIL, more detail you can see on my post here :

http://febru.soluvas.com/2014/03/solved-openerp-7-ioerror-decoder-zip.html

Solution 11 - Python

Mac OS X PIL JEPG and PNG issues (same for linux os), this Post help me out of both PNG and JPEG issues with PIL : decoder zip not available and decoder jpeg not available

Make sure JPEG and ZLIB are available, when you install / reinstall PIL :

$ cd Imaging-1.1.7
$ python setup.py build_ext -i
$ python selftest.py

--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
*** FREETYPE2 support not available
*** LITTLECMS support not available
--------------------------------------------------------------------

Solution 12 - Python

I tried the version 2.8.0 it works fine me

pip install -Iv Pillow==2.8.0

Solution 13 - Python

On Ubuntu 18 I have had to install pillow 2.8.1:

pip install Pillow==2.8.1

Solution 14 - Python

Try: $ sudo apt-get install python-dev $ sudo apt-get install libjpeg8-dev $ sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib Starting from version 3.0.0 Pillow needs libjpeg. If the issue persists, there might be some package incompatibility. Save some time and try the previous version: $ pip install Pillow==2.8.1

Solution 15 - Python

You should match Pillow's version your python version.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDevXView Question on Stackoverflow
Solution 1 - PythonCoryView Answer on Stackoverflow
Solution 2 - PythonyodiView Answer on Stackoverflow
Solution 3 - PythonJohnny ZhaoView Answer on Stackoverflow
Solution 4 - PythonJon-EricView Answer on Stackoverflow
Solution 5 - PythonJohn PangView Answer on Stackoverflow
Solution 6 - PythonAlmoView Answer on Stackoverflow
Solution 7 - Pythonmonika mevenkampView Answer on Stackoverflow
Solution 8 - PythonwoodratView Answer on Stackoverflow
Solution 9 - PythonchiraleView Answer on Stackoverflow
Solution 10 - Pythonuser3432013View Answer on Stackoverflow
Solution 11 - PythonisaacselementView Answer on Stackoverflow
Solution 12 - PythonSuresh VelusamyView Answer on Stackoverflow
Solution 13 - PythonKenlyView Answer on Stackoverflow
Solution 14 - PythonVargha HokmranView Answer on Stackoverflow
Solution 15 - PythonBrajendra JhaView Answer on Stackoverflow