AttributeError: type object 'Image' has no attribute 'open'

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Hlh\AppData\Local\Programs\Python\Python35\lib\tkinter_init_.py", line 1550, in call
return self.func(*args)
File "E:/PythonProjects/Image2CharImage/img.py", line 60, in rgb2char
im = Image.open('abc.png')
AttributeError: type object 'Image' has no attribute 'open'

分析:
查看原因可知道异常是在Tkinter中的回调发生的,所以可能是引用库的顺序出错了。

AttributeError: type object 'Image' has no attribute 'open'_第1张图片
Paste_Image.png

按着思路做,最后原来是真的因为引用库的顺序错了才出现这个异常。对于菜鸟的我来说发现这个问题真难,不过最后还是解决了。

解决办法:
改变引用库的顺序


AttributeError: type object 'Image' has no attribute 'open'_第2张图片
Paste_Image.png

你可能感兴趣的:(AttributeError: type object 'Image' has no attribute 'open')