Home > python > Problems with PIL? Use Pillow instead!

Problems with PIL? Use Pillow instead!

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“.

  1. July 26, 2014 at 20:02

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

    that was a very valuable hint. Thanks.

  1. No trackbacks yet.

Leave a comment