質問

I'm trying to port a python program from OS X to Windows 7. This program processes a png with tkinter eg

self.logoImg = ImageTk.PhotoImage(Image.open('GrowthPathLogo.png'))

The code is failing with IOError: decoder zip not available

I've tried installing pip with pypm. Then I try building it with pip. At the end of the build process it reports that there is no support for png/zlib

I get the same errors with the python.org installation on Windows.

I'm stuck and I'm not skilled at building C libraries. Neither do I know how pip works. I have a gnu zlib library installed but it's not helping at all. I have Visual C++ 2008 Express installed, and at least that's working because pip does compile things successfully.

役に立ちましたか?

解決

Try the build here that's maintained by Christoph Gohlke. To build PIL yourself you need several libraries as mentioned in the README: libjpeg, zlib, freetype2, and littleCMS. Read USAGE.txt in zlib125-dll.zip for instructions on linking to zlib with Visual C++ or MinGW.

他のヒント

I know this is an old question, but I wanted to give my answer in case people run into the same problem as me.

The builds by Christoph Gohlke are awesome, when they work. However for my win7 machine with python 2.7 and most importantly 64bit, there is no precompiled binary with PNG support (zlib support). The Pillow 64bit Binary on that page fails on easy_install and can't be installed on my machine.

So if you want to solve this and the binary doesn't work you need to build Pillow your self with zlib support. To do this you need to download the latest Pillow source. Modify in setup.py the ZLIB_ROOT line to say:

ZLIB_ROOT = './zlib'

Now you have to build zlib for win64 bit as well, that's the tricky part. Download latest zlib source from their site (I tested on 1.2.5/1.2.8). Open visual studio command prompt for 64 bit (VERY IMPORTANT) My command prompt was called VS2012 x64 Cross Tools Command Prompt.

Go to the zlib source dir and run:

nmake -f win32/Makefile.msc

If it doesnt work try:

nmake -f win32/Makefile.msc AS=ml64 LOC="-DASMV -DASMINF" OBJA="inffasx64.obj gvmat64.obj inffas8664.obj"

Now you should have in the source directory the following files:

zlib.h
zconf.h
zutil.h (not sure this is needed)
zlib.lib
zdll.lib

Copy them into the Pillow source directory, into a directory called "zlib" Compile Pillow using "python setup.py build_ext -i" Install Pillow using "python setup.py install"

Pillow should now work with ZLIB (png) support. If you have some older Pillow/PIL installations, you might need to manually copy the _imaging.pyd and _imagingmath.pyd to the package installation folder of your python or virtual environment, to make sure you have the newly compiled ones.

You can now import _imaging and you have png support.

You can also add Libjpeg in the same way, compiling it manually, if needed.

Hope this helps anyone that encounters this problem.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top