Archive
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:
- http://obroll.com/install-python-pil-python-image-library-on-ubuntu-11-10-oneiric/
- http://www.lancejian.com/2011/04/04/pil-ioerror-decoder-jpeg-not-available.html
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
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.
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.
