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'》 Paste_Image.png

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

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

《AttributeError: type object 'Image' has no attribute 'open'》 Paste_Image.png

    原文作者:于阗
    原文地址: https://www.jianshu.com/p/fd51fac14394
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞