Jacob
Jacob

Reputation: 25

Python Tkinter Image saying 'no such file or directory'

I know many questions are out there on this but none of the solutions seem to have worked. Here is my code:

image_1 = PhotoImage(file="AeolusPavillion_01"); image_1 = subsample(2)
backImg = Label(screen, image=image_1).place(x=50,y=50)

The error I get when this is run is _tkinter.TclError: couldn't open "AeolusPavillion_01": no such file or directory

I have tried using tk.PhotoImage() and os.path. and using the actual path directory instead of the image name too but none of these have fixed it. e.g. c:/users/... The image file is within the same folder as the python file and I made sure it was a .png file too as I heard JPEGs don't work in tkinter.

Has anyone got any solutions to what I could try next?

Upvotes: 0

Views: 1855

Answers (1)

AksTheBoss123
AksTheBoss123

Reputation: 24

Just try doing

image_1 = PhotoImage(file="AeolusPavillion_01.jpg"); image_1 = subsample(2)
backImg = Label(screen, image=image_1).place(x=50,y=50)

or whatever file type it is

Upvotes: 1

Related Questions