0

I am currently working on designing a UI for my project using Tkinter. I tried to insert an image using this :

import Tkinter as tk
from PIL import ImageTk, Image

window = Tk()
window.title("Outlier Detection using Feature Grouping")
window.configure(background = "black")

path="C:/Users/user/Desktop/od in hd/Corr"
C = tk.Canvas(window, bg="blue", height=250, width=300)
img = ImageTk.PhotoImage(Image.open(path))

and I get the error :

IOError: [Errno 2] No such file or directory: 'C:/Users/user/Desktop/od in hd/Corr'

I went through the solutions in the other questions but did not understand them much as I am new to Tkinter. Why does it say that no file or directory exists? How can I insert an image to my UI? Is there any other way to do so?

Nnn
  • 191
  • 3
  • 9
  • Are you using python 2.7? You might need to install the PIL package to make sure it works fine. Have a look at this and the other answers in this thread: https://stackoverflow.com/a/26440856/5028532 – razdi Mar 20 '19 at 04:10
  • The error saying, the path does not exist. try inserting with correct path of your image. – Alif Jahan Mar 20 '19 at 04:12
  • 1
    If python is telling you a path doesn't exist, you can be certain it doesn't exist. Are you certain you have a file called "C:/Users/user/Desktop/od in hd/Corr"? Is it possible you have suffixes hidden and the file actually ends in .png or .gif or something? – Bryan Oakley Mar 20 '19 at 04:14
  • Also, you might need to add the extention of the image. If it is a jpeg, your path would be: path = "C:/Users/user/Desktop/od in hd/Corr.jpg" – razdi Mar 20 '19 at 04:14

0 Answers0