Python 关于 PIL 错误 -- IOError:decoder zip not available
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3544155/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
About the PIL Error -- IOError: decoder zip not available
提问by DevX
I am getting the:
我得到:
IOError: decoder zip not available
when I try to draw an image and save to a jpeg in PIL. Any thoughts on how to resolve this? PIL has worked fine for me in the past, when it comes to viewing/uploading images.
当我尝试绘制图像并保存到 PIL 中的 jpeg 时。关于如何解决这个问题的任何想法?过去,在查看/上传图像时,PIL 对我来说效果很好。
采纳答案by Jon-Eric
It likely only needs the zip decoder to save the jpeg. I think I needed to follow these steps in OS X to preview jpegs.
它可能只需要 zip 解码器来保存 jpeg。我想我需要在 OS X 中按照这些步骤来预览 jpeg。
It probably means you need to:
这可能意味着您需要:
- Download the PIL source.
- Download the zlib library.
- Point the PIL source to the zlib library.
- Build PIL.
- 下载PIL 源代码。
- 下载 zlib 库。
- 将 PIL 源指向 zlib 库。
- 构建 PIL。
回答by yodi
The more detail installation PIL with zlib library in Ubuntu 64 bit :
在 64 位 Ubuntu 中使用 zlib 库的更详细的安装 PIL:
http://obroll.com/install-python-pil-python-image-library-on-ubuntu-11-10-oneiric/
http://obroll.com/install-python-pil-python-image-library-on-ubuntu-11-10-oneiric/
For the lazy (credits to @meawopplfor the apt-get):
对于懒惰(学分@ meawoppl的apt-get):
$ sudo apt-get install libjpeg-dev zlib1g-dev
回答by Cory
sudo pip uninstall PIL
sudo pip install pillow
^^ fixed it for me.
^^ 为我修好了。
Pillowis a fork of PIL that is compatible with pip/setuptools and gets a little better maintenance. I haven't seen any API differences yet.
Pillow是 PIL 的一个分支,它与 pip/setuptools 兼容并且得到了更好的维护。我还没有看到任何 API 差异。
Edit: There is one notable API difference. PIL exposes Image as a top-level namespace, so you can
编辑:有一个显着的 API 差异。PIL 将 Image 作为顶级命名空间公开,因此您可以
import Image # in PIL only
but
但
from PIL import Image # in pillow or PIL
- Thanks, Leopd!
- 谢谢,利奥普!
回答by monika mevenkamp
on mac
在 Mac 上
sudo brew install lzlib # installs zlib
pip uninstall PIL
pip install PIL
回答by Johnny Zhao
I encountered this problem on a 64bit ubuntu 13.04 desktop versionand here is how I resolved it.
我在64 位 ubuntu 13.04 桌面版本上遇到了这个问题,这是我解决的方法。
try to reinstall PIL, and pay attention to the output info after you reinstalled:
尝试重新安装PIL,并注意重新安装后的输出信息:
---------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform linux2 2.7.4 (default, Sep 26 2013, 03:20:26)
[GCC 4.7.3]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available
*** ZLIB (PNG/ZIP) support not available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------
notice that there is a line :*** ZLIB (PNG/ZIP) support not available,
which means PIL have been built without ZLIB support, and I fixed it by doing this:
注意有一行 : *** ZLIB (PNG/ZIP) support not available,这意味着 PIL 是在没有 ZLIB 支持的情况下构建的,我通过这样做修复了它:
first you should have these packages install: libjpeg-dev libfreetype6-dev zlib1g-dev
首先你应该安装这些包:libjpeg-dev libfreetype6-dev zlib1g-dev
sudo apt-get install python-dev libjpeg-dev libfreetype6-dev zlib1g-dev
# create these links, if already exists, remove it and re-link it
ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib
# reinstall PIL
pip uninstall PIL
pip install PIL
This time, there should be a line --- ZLIB (PNG/ZIP) support availablein the output.
这一次,--- ZLIB (PNG/ZIP) support available输出中应该有一行。
Reference: http://jj.isgeek.net/2011/09/install-pil-with-jpeg-support-on-ubuntu-oneiric-64bits/
参考:http: //jj.isgeek.net/2011/09/install-pil-with-jpeg-support-on-ubuntu-oneiric-64bits/
回答by Almo
The way I fixed this on OS X Mavericks was by doing this:
我在 OS X Mavericks 上解决这个问题的方法是这样做:
Install brew:
安装酿造:
Install pip:
安装点:
http://www.pip-installer.org/en/latest/installing.html
http://www.pip-installer.org/en/latest/installing.html
With those in place, you can do this:
有了这些,您可以执行以下操作:
sudo brew install lzlib # installs zlib
pip uninstall PIL
pip install --no-index -f http://dist.plone.org/thirdparty/ -U PIL
After that, it was working fine. For an explanation of the third line, check this answer:
之后,它工作正常。有关第三行的说明,请查看此答案:
回答by user3432013
on my case, i just remore python-image, make sure that libz is ready then reinstall PIL, more detail you can see on my post here :
就我而言,我只是重新安装了 python-image,确保 libz 已准备好然后重新安装 PIL,您可以在我的帖子中看到更多详细信息:
http://febru.soluvas.com/2014/03/solved-openerp-7-ioerror-decoder-zip.html
http://febru.soluvas.com/2014/03/solved-openerp-7-ioerror-decoder-zip.html
回答by isaacselement
Mac OS X PIL JEPG and PNG issues(same for linux os), this Post help me out of both PNG and JPEG issues with PIL : decoder zip not availableand decoder jpeg not available
Mac OS X PIL JEPG 和 PNG 问题(Linux 操作系统相同),这篇文章帮助我解决了 PIL 的 PNG 和 JPEG 问题: decoder zip not available和decoder jpeg not available
Make sure JPEG and ZLIB are available, when you install / reinstall PIL :
安装/重新安装 PIL 时,请确保 JPEG 和 ZLIB 可用:
$ cd Imaging-1.1.7
$ python setup.py build_ext -i
$ python selftest.py
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
*** FREETYPE2 support not available
*** LITTLECMS support not available
--------------------------------------------------------------------
回答by John Pang
I encountered same problem. It seems to me that Pillow and pillow (different case in 'p') are two different packages. So, if you are using Pillow, pip install pillowmight not help. Here is my solution:
我遇到了同样的问题。在我看来,枕头和枕头('p' 中的大小写不同)是两个不同的包。因此,如果您使用 Pillow,pip install pillow可能无济于事。这是我的解决方案:
$ pip uninstall pillow
$ pip uninstall Pillow
$ sudo apt-get install libjpeg-dev zlib1g-dev
$ pip install -I Pillow
First two lines are to remove any pillow or Pillow package.
前两行是删除任何枕头或枕头包。
Third line is to install the two required packages.
第三行是安装两个需要的包。
Forth is re-install Pillow.
第四是重新安装 Pillow。
Note, if you are using virtualenv, pip install/uninstallmust be run under virtualenv
注意,如果你使用的是virtualenv,pip install/uninstall必须在virtualenv下运行
回答by woodrat
I use 64bit ubuntu 14.04LTS desktop version, and I tried Johnny Zhao's answer.
When
我使用 64 位 ubuntu 14.04LTS 桌面版,我尝试了 Johnny Zhao 的回答。
什么时候
exec sudo easy_install PIL
I got an error:
我有一个错误:
can't find freetype/fterrors.h
and I find freetype2 in /usr/include/
我在 /usr/include/ 中找到了 freetype2
You could solve it by:
你可以通过以下方式解决:
sudo ln -s /usr/include/freetype2 /usr/include/freetype
then install will be success
然后安装就会成功

