簡體   English   中英

_tkinter.TclError:無法識別圖像文件中的數據

[英]_tkinter.TclError: couldn't recognize data in image file

你好

所以我有一個Tkinter GUI程序,從一開始就使用.png圖像。

我使用PyCharm,它在Python3和Tkinter上都可以正常運行,而沒有任何外部模塊。

但是當我從終端運行它時,我得到了:

someUser@somePC:~/KeyRunner$ python3 windowLOGIN.py

Traceback (most recent call last):
File "windowLOGIN.py", line 141, in <module>
app = WindowLogin(root)
File "windowLOGIN.py", line 23, in __init__
img = tk.PhotoImage(file="keyrunnerlogo.png")
File "/home/someUser/anaconda3/lib/python3.6/tkinter/__init__.py", line 3539, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "/home/someUser/anaconda3/lib/python3.6/tkinter/__init__.py", line 3495, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)

_tkinter.TclError: couldn't recognize data in image file "keyrunnerlogo.png"

如果我使用sudo運行它,則可以正常運行,任何想法可以解決此問題嗎?

通過卸載anaconda3 (位於我的主目錄中)解決了問題,該工具的tkinter版本較低,而python則導入了它,而不是更好的版本。

我認為可以通過更新anaconda3軟件包來解決它,但這對我來說是不必要的。

感謝@Lafexlos告訴我檢查版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM