【问题标题】:PIL shows "broken data stream when reading image file" in virtualenvPIL 在 vi​​rtualenv 中显示“读取图像文件时数据流损坏”
【发布时间】:2011-11-09 23:51:22
【问题描述】:

我的 python 和 PIL 安装来自 Snow Leopard 上的 MacPorts。

当我尝试使用 PIL 在系统 python 中打开 JPG 图像时,我没有收到任何错误。

$ python
>>> import Image
>>> img = Image.open("test.jpg")
>>> img2 = img.resize((1,1))
>>> # no errors!!!

但是当我创建一个虚拟环境时

$ virtualenv --no-site-packages venv
$ cd venv/
$ source bin/activate
(venv) $ pip install PIL
...
(venv) $ python
>>> import Image
>>> img = Image.open("../test.jpg")
>>> img2 = img.resize((1,1))
...
IOError: broken data stream when reading image file

Here 是一个完整的转储,包括 PIL 的整个构建。

有什么想法吗?

【问题讨论】:

  • 你从中得到什么 >>> from PIL import _imaging >>> _imaging
  • 在 virtualenv 中:<module 'PIL._imaging' from '/Users/miki725/Development/venv/lib/python2.7/site-packages/PIL/_imaging.so'> 在系统中:<module 'PIL._imaging' from '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/_imaging.so'>
  • 对我来说似乎可以使用 python 2.7 和 py27-virtualenv 1.6.1。你用的是什么版本?

标签: python macos python-imaging-library virtualenv


【解决方案1】:

看起来这是个问题。

一般人们不应该再使用 PIL

试试枕头https://pypi.org/project/Pillow/

我敢打赌这在 venv 中会很好玩

【讨论】:

  • 是的。谢谢。枕头好多了。解决了这些错误。
猜你喜欢
  • 2017-07-16
  • 2015-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-05
  • 1970-01-01
  • 2016-05-10
相关资源
最近更新 更多