Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pillow (PIL) not supporting PNG files.. how to install ZLIB Compression Library?

I installed Pillow by doing

pip install Pillow

and I do not have PIL installed. After I installed Pillow, it said:

ZLIB (PNG/ZIP) support not available

and when I try to create a thumbnail of a PNG image, it gives me an error saying

IOError at /createThumbnail/
decoder zip not available

I read the Pillow documentation (http://pillow.readthedocs.org/en/latest/handbook/image-file-formats.html#png) and it said that in order to get PNG support, I need to "build and install the ZLIB compression library before building the Python Imaging Library. See the distribution README for details". I read the original PIL README (http://pillow.readthedocs.org/en/latest/original-readme.html) and it said to install

sudo apt-get install zlib1g-dev

I did this and Pillow still did not support PNG files. I even tried reinstalling Pillow but that didn't work either. Any idea how I can get Pillow to support PNG files?

EDIT: I download zlib from here: http://zlib.net/

and then followed the instructions here: http://petio.org/tools/zlib.html

I basically just extracted the downloaded file and then ran these codes from within the directory:

$ ./configure -s --prefix=/usr
$ make
$ sudo su
make install

and then I uninstalled and reinstalled Pillow and it does supprt PNG now, however, I am still getting the exact same error message (decoder zip not available).. any idea why?

like image 329
SilentDev Avatar asked Jul 17 '14 02:07

SilentDev


2 Answers

Read me:

Build the library. We recommend that you do an in-place build, and run the self test before installing.

    $ cd Imaging-1.1.7
    $ python setup.py build_ext -i
    $ python selftest.py

During the build process, the setup.py will display a summary report that lists what external components it found. The self- test will display a similar report, with what external components the tests found in the actual build files:

    ----------------------------------------------------------------
    PIL 1.1.7 SETUP SUMMARY
    ----------------------------------------------------------------
    *** TKINTER support not available (Tcl/Tk 8.5 libraries needed)
    --- JPEG support available
    --- ZLIB (PNG/ZIP) support available
    --- FREETYPE support available
    ----------------------------------------------------------------

Make sure that the optional components you need are included.

If the build script won't find a given component, you can edit the setup.py file and set the appropriate ROOT variable. For details, see instructions in the file.

If the build script finds the component, but the tests cannot identify it, try rebuilding all modules:

    $ python setup.py clean
    $ python setup.py build_ext -i
like image 100
Alex Kroll Avatar answered Oct 22 '22 22:10

Alex Kroll


This is what really helped me on OS X El Capitan when I run it in my virtualenv:

pip install -I --no-cache-dir pillow --global-option=build_ext --global-option="-I$(xcrun --show-sdk-path)/usr/include"

like image 4
Przemek Lewandowski Avatar answered Oct 22 '22 23:10

Przemek Lewandowski