sissa
sissa

Reputation: 1

Error: No file or directory found, Visual Studio Code, Tkinter. Python Image, ImageTk

logo = Image.open('file.png')

the error says "No such file or directory found." will update when i find a fix, or someone replies with a successful fix. thank you everyone.

The error is that the file is not in the same area as the project file, so the solution was to insert the full directory. Thank you!

Upvotes: 0

Views: 830

Answers (1)

Sam
Sam

Reputation: 731

The error is occurring because file.png may not be in the same directory as that of the working directory.

A simple fix would be to use raw string and paste the full directory (e.g. for windows -> C:\Users...).

logo = Image.open(r'C:\Users\Username\Desktop\file.png') # Make sure to use 'r' to index raw string, if not the Python would not recognize backslash as a string

Upvotes: 1

Related Questions