【问题标题】:IOError: encoder zip not available ubuntuIOError:编码器 zip 不可用 ubuntu
【发布时间】:2015-02-05 13:41:35
【问题描述】:

当我尝试运行使用 PIL 的 python 程序时出现以下错误。

Generate_Dot.py:14: RuntimeWarning: the frombuffer defaults may change in a future release; for portability, change the call to read:
  frombuffer(mode, size, data, 'raw', mode, 0, 1)
  img = Image.frombuffer('L', size, data)
Traceback (most recent call last):
  File "Generate_Dot.py", line 15, in <module>
    img.save('image.png')
  File "/home/kapil/python/lib/python2.7/site-packages/PIL-1.1.7-py2.7-linux-i686.egg/PIL/Image.py", line 1439, in save
    save_handler(self, fp, filename)
  File "/home/kapil/python/lib/python2.7/site-packages/PIL-1.1.7-py2.7-linux-i686.egg/PIL/PngImagePlugin.py", line 572, in _save
    ImageFile._save(im, _idat(fp, chunk), [("zip", (0,0)+im.size, 0, rawmode)])
  File "/home/kapil/python/lib/python2.7/site-packages/PIL-1.1.7-py2.7-linux-i686.egg/PIL/ImageFile.py", line 481, in _save
    e = Image._getencoder(im.mode, e, a, im.encoderconfig)
  File "/home/kapil/python/lib/python2.7/site-packages/PIL-1.1.7-py2.7-linux-i686.egg/PIL/Image.py", line 401, in _getencoder
    raise IOError("encoder %s not available" % encoder_name)
IOError: encoder zip not available

【问题讨论】:

标签: python python-2.7 python-imaging-library zlib pillow


【解决方案1】:

cpython 依赖于您系统中安装的各种第三方库。在这种情况下,需要“zip”来执行一些压缩。我猜在这种情况下它将是 gzip、compress 或 zlib 之一。您应该可以使用 yum 或 apt-get 轻松安装这些。

【讨论】:

  • 我没有 root 权限来通过 apt-get 下载和安装它。我在我的主目录中从源代码安装了 zlib,但我被困在如何将它链接到我安装在主目录中的 python 上。
  • 将带有 libz.so 的目录添加到您的 LD_LIBRARY_PATH 环境变量中。
  • 例如export LD_LIBRARY_PATH=~/mylibs/:$LD_LIBRARY_PATH
  • 尝试添加到PYTHONPATH 可能。
猜你喜欢
  • 2013-02-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-05-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多