【发布时间】:2016-09-03 18:40:04
【问题描述】:
我正在尝试执行此脚本
from PIL import Image
im = Image.open("image.jpg")
nx, ny = im.size
当我在 python shell 中运行它时它工作正常
pytesser_v0.0.1]#env python
>>> from PIL import Image
>>> im = Image.open("image.jpg")
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=46x24 at 0x7FA4688F16D0>
但是当我把它放在某个 test.py 文件中并像 python test.py 一样运行它时 我收到此错误
File "test1.py", line 17, in <module>
im = Image.open("image.jpg")
File "/usr/local/python.2.7.11/lib/python2.7/site-packages/PIL/Image.py", line 2309, in open
% (filename if filename else fp))
IOError: cannot identify image file 'image.jpg'
请帮我解决这个问题,谢谢
PS:之前我从 Imaging-1.1.7 setup.py 安装 PIL,后来我安装了 Pillow,我认为问题在于机器上 PIL 和 Pillow 库的相互存在。
【问题讨论】:
标签: python image python-2.7 python-imaging-library pillow