0

I use PIL and I have this error:

decoder zip not available

in this line: {% thumbnail design.img "511x400" crop="center" as im %}

Full:

{% thumbnail design.img "511x400" crop="center" as im %}
    <img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
{% endthumbnail %}

I use Django 1.5, PIL and virtualenv

How can I fix this error?

EDIT:

I try:

pip uninstall PIL
apt-get install libjpeg-dev
apt-get install libfreetype6-dev
apt-get install zlib1g-dev
apt-get install libpng12-dev
pip install PIL --upgrade

but it still does not work

Result from terminal:

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

To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.
madax
  • 39
  • 1
  • 9
  • Did you install PIL with libz support? Also check [this](http://stackoverflow.com/questions/15258335/ioerror-decoder-zip-not-available-ubuntu-python-pil) thread – Hedde van der Heide Aug 07 '13 at 09:15
  • @HeddevanderHeide: I installed: `pip install PIL` and after `pip install pil --upgrade` – madax Aug 07 '13 at 09:17
  • You need to have the zlib development headers installed for PIL to be able compile support. – Martijn Pieters Aug 07 '13 at 09:21
  • It seems your compiler cannot find the libraries you can create symlinks to the correct locations (see the PIL setup file), see this [post](http://jj.isgeek.net/2011/09/install-pil-with-jpeg-support-on-ubuntu-oneiric-64bits/) – Hedde van der Heide Aug 07 '13 at 09:47
  • Are you certain the egg was recompiled? `--upgrade` doesn't necessarily do so; either uninstall and reinstall, or use `install --upgrade --force-reinstall`. – Martijn Pieters Aug 07 '13 at 09:48
  • 1
    You may also want to look into `Pillow`, which is a fork of `PIL` fixing packaging issues, outstanding bugs and adding Python 3 support. – Martijn Pieters Aug 07 '13 at 09:49
  • @HeddevanderHeide I created symlinks – madax Aug 07 '13 at 09:54
  • Check http://stackoverflow.com/questions/8915296/decoder-jpeg-not-available-pil. Make sure you have libjpeg-dev and that it's there on path else symlink it to /usr/lib. Once you do this, reinstall PIL. – Akshar Raaj Aug 07 '13 at 11:56

1 Answers1

1

Original PIL sucks!

I tried to install all required dependencies, linking all the files, which cost me one whole morning, still not working even though.

Solution: Use Pillow

  sudo pip install PIL

Then you can:

  $ 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.
  >>> from PIL import Image
  >>>

Reference: http://pythonadventures.wordpress.com/2013/05/19/problems-with-pil-use-pillow-instead/

Oliver Hu
  • 81
  • 8