Archive

Posts Tagged ‘pil’

Problems with PIL? Use Pillow instead!

May 19, 2013 1 comment

Problem
PIL started to report the following error: “IOError: decoder zip not available“. I tried to solve this issue following these tips but I had no luck:

The funny thing is that PIL shows the following statistics:

--------------------------------------------------------------------
    PIL 1.1.7 SETUP SUMMARY
    --------------------------------------------------------------------
    version       1.1.7
    platform      linux2 2.7.4 (default, Apr 19 2013, 18:28:01)
                  [GCC 4.7.3]
    --------------------------------------------------------------------
    *** TKINTER support not available (Tcl/Tk 8.5 libraries needed)
    --- JPEG support available
    --- ZLIB (PNG/ZIP) support available
    --- FREETYPE2 support available
    *** LITTLECMS support not available
    --------------------------------------------------------------------

Notice the line “ZLIB (PNG/ZIP) support available“. That’s a lie! :)

Solution
I got fed up with PIL and switched to Pillow, which is a fork of PIL. It solved the problem for me. Remove PIL and install Pillow:

sudo pip uninstall PIL
sudo pip install pillow -U

Pillow produces the following statistics:

--------------------------------------------------------------------
    SETUP SUMMARY (Pillow 2.0.0 fork, originally based on PIL 1.1.7)
    --------------------------------------------------------------------
    version      2.0.0 (Pillow)
    platform     linux2 2.7.4 (default, Apr 19 2013, 18:28:01)
                 [GCC 4.7.3]
    --------------------------------------------------------------------
    *** TKINTER support not available
    (Tcl/Tk 8.5 libraries needed)
    --- JPEG support available
    --- ZLIB (PNG/ZIP) support available
    *** TIFF G3/G4 (experimental) support not available
    --- FREETYPE2 support available
    *** LITTLECMS support not available
    *** WEBP support not available
    --------------------------------------------------------------------

Now test if everything is OK:

$ python
Python 2.7.4 (default, Apr 19 2013, 18:28:01) 
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Image
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named Image
>>> from PIL import Image
>>>

The first attempt is used with PIL. If it fails: good, PIL is removed. The second one is for Pillow. If you can import successfully: good!

If you want to port an existing PIL project to Pillow, just replace “import Image” with “from PIL import Image“.

Python PIL : IOError: decoder jpeg not available

December 2, 2012 Leave a comment

Problem
Working with JPG files, PIL drops the following error:

Python PIL : IOError: decoder jpeg not available

Solution

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

Found here.

Categories: python Tags: , , , ,

Installation of PIL under Ubuntu

Problem
Using PIL, I ran in the following error: “decoder zip not available”.

Solution
I found the solution here. Here I make a summary:

sudo pip uninstall PIL
sudo apt-get install libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev
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
sudo pip install -U PIL

Credits
Tip from here.

Categories: python Tags: