0

Hello

So I have a Tkinter GUI'd program, that uses .png image right from start.

I use PyCharm and it works all alright with Python3 and Tkinter, without any external modules.

But when I run it from terminal I get this:

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"

If I run it with sudo it runs alright, any idea what can fix this?

5
  • 1
    What is your tkinter version? import tkinter; tkinter.TkVersion Commented Aug 17, 2017 at 14:41
  • @Lafexlos My tkinter version is 8.5 Commented Aug 17, 2017 at 16:26
  • It's 8.6 when python is started as super user, ok. Commented Aug 17, 2017 at 16:28
  • So I think it grabs wrong Tkinter version from Anaconda. Commented Aug 17, 2017 at 16:32
  • Glad you worked it out. :) Commented Aug 17, 2017 at 19:45

1 Answer 1

1

Problem was solved by uninstalling anaconda3 (that was sitting in my home directory), it had lower version of tkinter and python imported it instead of a better one.

I think it could've been solved by updating anaconda3 packages, but it was unnecessary for me.

Thanks to @Lafexlos for telling me to check versions.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.