PIL在virtualenv中显示“读取图像文件时损坏的数据流”

时间:2011-11-09 23:51:22

标签: python macos python-imaging-library virtualenv

我的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版本。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

看起来这是一个问题。

通常人们不应再使用PIL了

试试枕头https://pypi.python.org/pypi/Pillow/2.4.0

我愿意打赌这在venv中表现得很好