I see this question asked all over the internet, and I've tried following them all, but I still can't get PIL to work.
I tried symbolically linking the zlib, jpeg, etc. libraries via:
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 ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/
I tried editing the setup.py
file, adding this line:
add_directory(library_dirs, "/usr/lib/x86_64-linux-gnu")
In fact, running $ sudo python setup.py install
shows that JPEG, ZLIB/PNG, etc. support is Available. (I'm installing it for both 2.5 and 2.7, works in neither)
sudo python2.5 setup.py install
running install
running build
running build_py
running build_ext
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.5.6 (r256:88840, Feb 1 2012, 15:55:08)
[GCC 4.5.2]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
--- LITTLECMS support available
But after all that, I still get a decoder %s not available
error.
I'm at my wits end. Anything else I might have missed?
My environment: 64-bit Ubuntu 11.04 running in a VirtualBox VM.
Here's what I do to test if PIL works or not
$ python
>>> from PIL import Image
>>> im = Image.open("photo.jpg")
>>> im.rotate(45)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1359, in rotate
self.load()
File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 189, in load
d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 385, in _getdecoder
raise IOError("decoder %s not available" % decoder_name)
IOError: decoder zip not available
>>>
As always, use the package manager:
sudo apt-get install python-imaging
It'll deal with it all for you. The packages are available.
Manually installing, in any Linux distro, is a wasted endeavour, unless the packages really don't exist. Package maintainers spend time ensuring that the package works and installs correctly, there is no point duplicating their effort. Especially not to manually install something that then doesn't have the advantages of a package - no automatic updating, no easy removal, etc...
I have successfully reinstalled PIL in Ubuntu 12.04 like this:
pip uninstall PIL
apt-get install libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev
ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib/
ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/
ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/
pip install -U PIL
It does not raise the IOError: decoder zip not available
anymore after reinstalling the PIL. My error traceback was:
Traceback (most recent call last):
File "convert_image.py", line 15, in <module>
image.save('output.png')
File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1406, in save
self.load()
File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 189, in load
d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 385, in _getdecoder
raise IOError("decoder %s not available" % decoder_name)
IOError: decoder zip not available
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With