我的python和PIL安装是来自雪豹上的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
这是一个完整的转储,包括PIL的整个构建。
任何想法?
看来这是个问题。
一般来说,人们不应该再使用PIL了
试试Pillow https://pypi.org/project/Pillow/
我敢打赌这在venv