我正在收到:
IOError: decoder zip not available
当我尝试在PIL中绘制一张图片并将其保存为jpeg格式时,遇到了问题。有什么想法来解决这个问题吗?在查看/上传图像方面,PIL对我来说一直都很好用。
我正在收到:
IOError: decoder zip not available
当我尝试在PIL中绘制一张图片并将其保存为jpeg格式时,遇到了问题。有什么想法来解决这个问题吗?在查看/上传图像方面,PIL对我来说一直都很好用。
sudo pip uninstall PIL
sudo pip install pillow
^^对我很有帮助。
Pillow是PIL的一个分支,兼容pip/setuptools并得到了更好的维护。我还没有看到任何API差异。
编辑:有一个值得注意的API差异。PIL公开了Image作为顶级命名空间,因此您可以
import Image # in PIL only
但是
from PIL import Image # in pillow or PIL
在Ubuntu 64位系统中安装带有zlib库的PIL的详细步骤:
http://obroll.com/install-python-pil-python-image-library-on-ubuntu-11-10-oneiric/
懒人专属(感谢@meawoppl提供的apt-get
命令):
$ sudo apt-get install libjpeg-dev zlib1g-dev
我在一台64位的ubuntu 13.04桌面版遇到了这个问题,以下是我是如何解决的。
尝试重新安装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
--------------------------------------------------------------------
请注意这一行:*** ZLIB (PNG/ZIP) support not available
,意味着PIL没有构建ZLIB支持,我通过以下方式进行了修复:
首先您需要安装这些软件包: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
这次输出中应该有一行 --- ZLIB(PNG/ZIP)支持可用
。
参考: http://jj.isgeek.net/2011/09/install-pil-with-jpeg-support-on-ubuntu-oneiric-64bits/
这可能只需要zip解码器就能保存JPEG文件。我认为在OS X中,我需要按照以下步骤来预览JPEG文件:
这可能意味着你需要:
我遇到了同样的问题。看起来Pillow和pillow('p'的大小写不同)是两个不同的软件包。所以,如果你正在使用Pillow,pip install pillow
可能无法解决问题。这是我的解决方案:
$ pip uninstall Pillow
$ sudo apt-get install libjpeg-dev zlib1g-dev
$ pip install -I Pillow
首先,前两行代码是为了卸载任何已安装的pillow或Pillow包。
第三行代码是用来安装两个必需的包。
第四行代码是重新安装Pillow。
请注意,如果您正在使用虚拟环境,则必须在虚拟环境下运行pip install/uninstall
命令。
http://www.pip-installer.org/en/latest/installing.html
有了这些,你可以这样做:sudo brew install lzlib # installs zlib
pip uninstall PIL
pip install --no-index -f http://dist.plone.org/thirdparty/ -U PIL
exec sudo easy_install PIL
我收到一个错误:
can't find freetype/fterrors.h
我在 /usr/include/ 中找到了 freetype2。
你可以通过以下方法解决:
sudo ln -s /usr/include/freetype2 /usr/include/freetype
然后安装将成功
apt-get install python-imaging
安装了python-imaging。如果只单独安装libjpeg-dev libfreetype6-dev zlib1g-dev
而不安装所有的python-imaging,就不会出现这个错误。 - Nick Sweetingsudo brew install lzlib # installs zlib
pip uninstall PIL
pip install PIL
sudo brew install lzlib
只会显示"brew: command not found"。 - Almoyum install zlib zlib-devel
pip install Pillow --upgrade
如果您正在使用的是Web应用程序,请重新启动您的Web服务器以应用更改。
Mac OS X PIL JEPG和PNG问题(Linux操作系统也一样),这篇文章帮助我解决了PIL的PNG和JPEG问题: 解码器zip不可用和解码器jpeg不可用
在安装/重新安装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
--------------------------------------------------------------------
import Image
可以工作,但在 Pillow 中不行。Pillow 需要使用from PIL import Image
。 - Leopdpip --no-cache-dir install Pillow
。 - Tianwei Chen