关于PIL错误- IOError:解码器zip不可用

时间:2021-07-11 00:26:09

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过去对我来说,在查看/上传图片的时候很好用。

13 个解决方案

#1


11  

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:

它可能意味着你需要:

#2


114  

sudo pip uninstall PIL
sudo pip install pillow 

^^ fixed it for me.

^ ^我固定它。

Pillow is 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将图像公开为*名称空间,所以可以这样做

import Image # in PIL only

but

from PIL import Image  # in pillow or PIL
  • Thanks, Leopd!
  • 谢谢,Leopd !

#3


39  

The more detail installation PIL with zlib library in Ubuntu 64 bit :

更详细的安装PIL和zlib库在ubuntu64位:

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 @meawoppl for the apt-get):

对于懒惰者(为apt-get归功于@meawoppl):

$ sudo apt-get install libjpeg-dev zlib1g-dev

#4


17  

I encountered this problem on a 64bit ubuntu 13.04 desktop version and 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)支持不可用,这意味着PIL已经在没有ZLIB支持的情况下构建了PIL,我这样做是为了修复它:

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 available in the output.

这一次,在输出中应该有一行--- ZLIB (PNG/ZIP)支持。

Reference: http://jj.isgeek.net/2011/09/install-pil-with-jpeg-support-on-ubuntu-oneiric-64bits/

参考:http://jj.isgeek.net/2011/09/install——公益诉讼与- jpeg -支持- 64 - bits/ ubuntu -梦的

#5


7  

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 pillow might not help. Here is my solution:

我遇到了同样的问题。在我看来,枕头和枕头(p中的不同情况)是两个不同的包裹。所以,如果你正在使用枕头,pip安装枕头可能没有帮助。这是我的解决方案:

$ 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.

是重新安装的枕头。

Note, if you are using virtualenv, pip install/uninstall must be run under virtualenv

注意,如果您正在使用virtualenv, pip安装/卸载必须在virtualenv下运行

#6


2  

The way I fixed this on OS X Mavericks was by doing this:

我对OS X Mavericks的修正方法是:

Install brew:

安装酿造:

http://brew.sh/

http://brew.sh/

Install pip:

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:

在那之后,一切都很顺利。对于第三行的解释,请检查这个答案:

https://*.com/a/2486396/290072

https://*.com/a/2486396/290072

#7


1  

on mac

在mac

sudo brew install lzlib     # installs zlib
pip uninstall PIL
pip install PIL

#8


1  

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

然后安装将会成功

#9


1  

The cause may be you've installed Pillow without zlib support.

原因可能是你安装了没有zlib支持的枕头。

On CentOS 7:

在CentOS 7:

yum install zlib zlib-devel
pip install Pillow --upgrade

And if you are using for a webapp restart your webserver to apply.

如果你正在使用webapp重新启动你的webserver应用。

#10


0  

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 :

在我的例子中,我只是remore 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

#11


0  

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 available and decoder jpeg not available

Mac OS X PIL JEPG和PNG问题(linux OS也是如此),这篇文章帮助我解决了PIL和JPEG问题:解码器zip不可用,解码器JPEG不可用

Make sure JPEG and ZLIB are available, when you install / reinstall PIL :

确保JPEG和ZLIB在安装/重新安装PIL时可用:

$ 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
--------------------------------------------------------------------

#12


0  

I tried the version 2.8.0 it works fine me

我试用了2.8.0版本,我觉得不错

pip install -Iv Pillow==2.8.0

#13


0  

On Ubuntu 18 I have had to install pillow 2.8.1:

在Ubuntu 18上,我必须安装枕头2.8.1:

pip install Pillow==2.8.1

#1


11  

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:

它可能意味着你需要:

#2


114  

sudo pip uninstall PIL
sudo pip install pillow 

^^ fixed it for me.

^ ^我固定它。

Pillow is 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将图像公开为*名称空间,所以可以这样做

import Image # in PIL only

but

from PIL import Image  # in pillow or PIL
  • Thanks, Leopd!
  • 谢谢,Leopd !

#3


39  

The more detail installation PIL with zlib library in Ubuntu 64 bit :

更详细的安装PIL和zlib库在ubuntu64位:

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 @meawoppl for the apt-get):

对于懒惰者(为apt-get归功于@meawoppl):

$ sudo apt-get install libjpeg-dev zlib1g-dev

#4


17  

I encountered this problem on a 64bit ubuntu 13.04 desktop version and 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)支持不可用,这意味着PIL已经在没有ZLIB支持的情况下构建了PIL,我这样做是为了修复它:

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 available in the output.

这一次,在输出中应该有一行--- ZLIB (PNG/ZIP)支持。

Reference: http://jj.isgeek.net/2011/09/install-pil-with-jpeg-support-on-ubuntu-oneiric-64bits/

参考:http://jj.isgeek.net/2011/09/install——公益诉讼与- jpeg -支持- 64 - bits/ ubuntu -梦的

#5


7  

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 pillow might not help. Here is my solution:

我遇到了同样的问题。在我看来,枕头和枕头(p中的不同情况)是两个不同的包裹。所以,如果你正在使用枕头,pip安装枕头可能没有帮助。这是我的解决方案:

$ 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.

是重新安装的枕头。

Note, if you are using virtualenv, pip install/uninstall must be run under virtualenv

注意,如果您正在使用virtualenv, pip安装/卸载必须在virtualenv下运行

#6


2  

The way I fixed this on OS X Mavericks was by doing this:

我对OS X Mavericks的修正方法是:

Install brew:

安装酿造:

http://brew.sh/

http://brew.sh/

Install pip:

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:

在那之后,一切都很顺利。对于第三行的解释,请检查这个答案:

https://*.com/a/2486396/290072

https://*.com/a/2486396/290072

#7


1  

on mac

在mac

sudo brew install lzlib     # installs zlib
pip uninstall PIL
pip install PIL

#8


1  

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

然后安装将会成功

#9


1  

The cause may be you've installed Pillow without zlib support.

原因可能是你安装了没有zlib支持的枕头。

On CentOS 7:

在CentOS 7:

yum install zlib zlib-devel
pip install Pillow --upgrade

And if you are using for a webapp restart your webserver to apply.

如果你正在使用webapp重新启动你的webserver应用。

#10


0  

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 :

在我的例子中,我只是remore 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

#11


0  

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 available and decoder jpeg not available

Mac OS X PIL JEPG和PNG问题(linux OS也是如此),这篇文章帮助我解决了PIL和JPEG问题:解码器zip不可用,解码器JPEG不可用

Make sure JPEG and ZLIB are available, when you install / reinstall PIL :

确保JPEG和ZLIB在安装/重新安装PIL时可用:

$ 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
--------------------------------------------------------------------

#12


0  

I tried the version 2.8.0 it works fine me

我试用了2.8.0版本,我觉得不错

pip install -Iv Pillow==2.8.0

#13


0  

On Ubuntu 18 I have had to install pillow 2.8.1:

在Ubuntu 18上,我必须安装枕头2.8.1:

pip install Pillow==2.8.1