"IOError: decoder zip not available" : Ubuntu Python PIL
Asked Answered
A

5

11

I am trying to get the sample heatmap.py running from: http://jjguy.com/heatmap/

#image.py
import heatmap
import random

if __name__ == "__main__":    
    pts = []
    for x in range(400):
        pts.append((random.random(), random.random() ))

    print "Processing %d points..." % len(pts)

    hm = heatmap.Heatmap()
    img = hm.heatmap(pts)
    img.save("classic.png")

and I get this error:

Processing 400 points...
Traceback (most recent call last):
  File "/home/ec2usr/workspace/image/image.py", line 14, in <module>
    img.save("classic.png")
  File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1437, in save
    save_handler(self, fp, filename)
  File "/usr/local/lib/python2.7/dist-packages/PIL/PngImagePlugin.py", line 572, in _save
    ImageFile._save(im, _idat(fp, chunk), [("zip", (0,0)+im.size, 0, rawmode)])
  File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 481, in _save
    e = Image._getencoder(im.mode, e, a, im.encoderconfig)
  File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 399, in _getencoder
    raise IOError("encoder %s not available" % encoder_name)
IOError: encoder zip not available

Working off of Eclipse on an Ubuntu 12 (64bit) system, with Python 2.7.

I find libz.so in both /usr/lib and /usr/lib/x86_64-linux-gnu/ just fine. I've tried these solutions already without result:

PIL says it has "support available" but still gives IOError when saving files

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

IOError: "decoder zip not available" using matplotlib PNG in ReportLab on Linux, works on Windows

http://www.foxhop.net/ubuntu-python-easy_install-pil-does-not-install-zlib-support

I've been pulling my hair out over this for a few days and greatly appreciate anyone's help!

Install Log from python-imaging:

ubuntu@ip-10-241-17-21:/usr/lib$ sudo apt-get install python-imaging
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  account-plugin-identica account-plugin-twitter gir1.2-messagingmenu-1.0
  hplip-data libgtkspell-3-0 libqt4-designer libqt4-help libqt4-scripttools
  libqt4-svg libqt4-test libqtassistantclient4 libsane-hpaio
  linux-headers-3.5.0-21 linux-headers-3.5.0-21-generic python-debtagshw
  python-lxml python-pexpect python-piston-mini-client python-qt4
  python-renderpm python-reportlab python-reportlab-accel python-sip
  software-center-aptdaemon-plugins ubuntu-extras-keyring
Use 'apt-get autoremove' to remove them.
Suggested packages:
  python-imaging-doc python-imaging-dbg
The following NEW packages will be installed:
  python-imaging
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/294 kB of archives.
After this operation, 996 kB of additional disk space will be used.
Selecting previously unselected package python-imaging.
(Reading database ... 189302 files and directories currently installed.)
Unpacking python-imaging (from .../python-imaging_1.1.7-4build1_amd64.deb) ...
Setting up python-imaging (1.1.7-4build1) ...
ubuntu@ip-10-241-17-21:/usr/lib$

log from install ( python install setup.py from Imaging) :

PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version       1.1.7
platform      linux2 2.7.3 (default, Sep 26 2012, 21:51:14)
              [GCC 4.7.2]
--------------------------------------------------------------------
--- TKINTER support available
*** JPEG support not available
--- ZLIB (PNG/ZIP) support available
*** FREETYPE2 support not available
*** LITTLECMS support not available

selftest.py:

--------------------------------------------------------------------
PIL 1.1.7 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from ./PIL
Binary modules loaded from /usr/local/lib/python2.7/dist-packages
--------------------------------------------------------------------
*** 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
--------------------------------------------------------------------
Ageold answered 6/3, 2013 at 21:22 Comment(8)
Did you have libz.so there when you installed PIL?Lunch
I believe so, but I also reintalled PIL egg with sudo apt-get build-dep python-imaging afterwards, just in case.Ageold
update: .tif works ok; png and jpg don't work.Ageold
Also, if I remember correctly PIL prints a list of supported and unsupported formats during the installation.Lunch
just added the install log from console, didn't see anything on formats.Ageold
Wait, so you think you are using the module from the distribution package?Lunch
sorry, you're right, I didn't include the right log from console. From the install is now added above. JPEG not available.Ageold
I also just added selftest.py above. There it says that JPEG and ZLIB are indeed supoorted, but PIL Core is not. Now I am really confused. Thanks for any insights!Ageold
I
9

I just encountered a similar issue caused by having both PIL (installed through the python pip installer) and the python-imaging package installed via apt-get. When I removed the extra version from pip that resolved it for me.

If you installed PIL from source or using pip then you might have the same problem.

When I was building PIL I also discovered that I had to link over the libraries to /usr/lib. That might resolve the not supported messages in your log above.

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
Icefall answered 18/6, 2013 at 23:39 Comment(0)
A
7

I remember arriving at the exact same solution as Kris did when installing PIL on 64 bit systems.

However nowadays I would recommend using Pillow (pip install pillow) instead of PIL. Pillow is simply a fork of PIL with more frequent releases and less issues like the one you're experiencing.

If you're on Ubuntu I think you need zlib1g-dev and libjpeg-dev installed before installing PIL/Pillow so that you get support for jpeg/png built in.

Abyss answered 19/6, 2013 at 0:1 Comment(2)
Here to confirm that you need to install dependencies before installing PIL/Pillow, so the installation process performs the proper compilation steps.Lituus
This was the correct answer for me and it works on Ubuntu 12.04 and 14.04 both with python 2.7 and 3.4Missi
F
2

Even though my PIL was up to date, I resolved this on Ubuntu 12.04 with:

pip uninstall PIL
pip install PIL
Footrope answered 20/8, 2013 at 4:58 Comment(0)
G
2

This worked Perfectly for me:

apt-get install libjpeg62 libjpeg62-dev zlib1g-dev libfreetype6 libfreetype6-dev

In x86_64:

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

In i386:

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


pip install -U PIL --allow-external PIL --allow-unverified PIL
pip install -I pillow
Gaspar answered 10/12, 2014 at 21:54 Comment(0)
F
0

even you test with

from PIL import image

is okay, but there is still error on save/decode methods.

you can try my steps: (base on my case, openerp 7 with ubuntu 13.10)

  1. remove python image
  2. locate your libz
  3. reinstall PIL

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

Fayth answered 18/3, 2014 at 7:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.