我正在制作一个数字助理(一个非恶意软件 BonziBuddy 克隆,如果你愿意的话),当我尝试在“字符”窗口中显示图像时,会发生此错误,我收到此错误。这是我的代码:
Traceback (most recent call last): File "/home/runner/Mon/main.py", line 30, in <module> pyimage1 = ImageTk.PhotoImage(file=PIL.Image.open("assets/1.png")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/runner/Mon/.pythonlibs/lib/python3.11/site-packages/PIL/ImageTk.py", line 102, in __init__ image = _get_image_from_kw(kw) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/runner/Mon/.pythonlibs/lib/python3.11/site-packages/PIL/ImageTk.py", line 59, in _get_image_from_kw return Image.open(source) ^^^^^^^^^^^^^^^^^^ File "/home/runner/Mon/.pythonlibs/lib/python3.11/site-packages/PIL/Image.py", line 3442, in open prefix = fp.read(16) ^^^^^^^ AttributeError: 'PngImageFile' object has no attribute 'read' Exception ignored in: <function PhotoImage.__del__ at 0x7e67e762ea20> Traceback (most recent call last): File "/home/runner/Mon/.pythonlibs/lib/python3.11/site-packages/PIL/ImageTk.py", line 132, in __del__ name = self.__photo.name ^^^^^^^^^^^^ AttributeError: 'PhotoImage' object has no attribute '_PhotoImage__photo'
错误如下:
File "/home/runner/Mon/.pythonlibs/lib/python3.11/site-packages/PIL/ImageTk.py", line 102, in __init__ image = _get_image_from_kw(kw) ^^^^^^^^^^^^^^^^^^^^^^ File "/home/runner/Mon/.pythonlibs/lib/python3.11/site-packages/PIL/ImageTk.py", line 59, in _get_image_from_kw return Image.open(source) ^^^^^^^^^^^^^^^^^^ File "/home/runner/Mon/.pythonlibs/lib/python3.11/site-packages/PIL/Image.py", line 3442, in open prefix = fp.read(16) ^^^^^^^ AttributeError: 'PngImageFile' object has no attribute 'read' Exception ignored in: <function PhotoImage.__del__ at 0x7e67e762ea20> Traceback (most recent call last): File "/home/runner/Mon/.pythonlibs/lib/python3.11/site-packages/PIL/ImageTk.py", line 132, in __del__ name = self.__photo.name ^^^^^^^^^^^^ AttributeError: 'PhotoImage' object has no attribute '_PhotoImage__photo'
如果您不向我们提供您的源代码(您的文件以 .py" 结尾),我们将很难为您提供帮助。请输入您的源代码,以便我们提供帮助。如果您有任何 API 令牌,请确保不要包含它以避免被其他用户使用。
干杯,
赫克托