0

The code:

from tkinter import*
from PIL import Image, ImageTk

class Login_System:
    def __init__(self,root):
        self.root=root
        self.root.title("Login System")
        self.root.geometry("1350x700+0+0")
        
        img = Image.open('images\background.jpg')
        self.bg_icon=ImageTk.PhotoImage(img)

root=Tk()
obj=Login_System(root)
root.mainloop()

The error:

Traceback (most recent call last): File "c:\PythonLoginSystem\login.py", line 15, in <module> obj=Login_System(root) File "c:\PythonLoginSystem\login.py", line 11, in init img = Image.open('images\background.jpg') File "C:\Users\Administrator\AppData\Roaming\Python\Python310\site-packages\PIL\Image.py", line 3131, in open fp = builtins.open(filename, "rb") OSError: [Errno 22] Invalid argument: 'images\x08ackground.jpg'

/images path

I checked the image path and I didn't see anything wrong with it. I tried 'images/background.jpg', r'images\background.jpg', 'images\background.jpg', but none of them worked

Cat Ball
  • 1
  • 1
  • `\b` is the escape sequence for backspace in strings, which Windows doesn't allow in filenames. Use a raw string, double the backslash, or use a forward slash. – Barmar Jun 21 '23 at 15:11

0 Answers0