_tkinter.TclError: image "pyimage2" doesn't exist

Hi guys,

I am working on a sort of project where i need to show a button on which an image is deployed. The first widow shows the image perfectly, but when the same or the copied image of the original image is called by the function, it shows the error which is the topic of the question…

The first window code, which works correctly-

from tkinter import *
import sqlite3
from app import main
from tkinter import messagebox
from PIL import ImageTk, Image
import os
from new_account import new_acc_main


def login_main():
    conn = sqlite3.connect("meta_data.db")
    c = conn.cursor()

    def onclick():# Function for clicking button
        def validate(username, userpass):
            access = False
            c.execute("SELECT User_Name, User_pass FROM user_data;")
            data = c.fetchall()
            for i in data:
                if i[0] == username:
                    if i[1] == userpass:
                        access = True
                        name_entry.delete(0, END)
                        pass_entry.delete(0, END)
                        messagebox.showinfo("Account Verified", message="Your Account is Verified. Redirecting you to DashBoard.")
                        root.destroy()
                        main()
                        break
                    else:
                        continue

                else:
                    continue

            if not(access):
                name_entry.delete(0, END)
                pass_entry.delete(0, END)
                messagebox.showerror('Account Not Found', message="Your Account is not verified. Retry Later.")
                

            

        u_name = name_entry.get()
        u_pass = pass_entry.get()
        validate(u_name, u_pass)

    def step_1(event):# Function for clicking enter button
        def validate(username, userpass):
            access = False
            c.execute("SELECT User_Name, User_pass FROM user_data;")
            data = c.fetchall()
            for i in data:
                if i[0] == username:
                    if i[1] == userpass:
                        access = True
                        name_entry.delete(0, END)
                        pass_entry.delete(0, END)
                        messagebox.showinfo("Account Verified", message="Your Account is Verified. Redirecting you to DashBoard.")
                        root.destroy()
                        main()
                        break
                    else:
                        continue

                else:
                    continue

            if not(access):
                messagebox.showerror('Account Not Found', message="Your Account is not verified. Retry Later.")

            

        u_name = name_entry.get()
        u_pass = pass_entry.get()
        validate(u_name, u_pass)

    def some_callback(event):
        name_entry.delete(0, END)
        pass_entry.delete(0, END)
        return None
    root = Tk()
    root.resizable(0, 0)
    value = StringVar()
    value.set("Username")
    val = StringVar()
    val.set("Password")
    root.title("Login Page")
    root.config(bg="#222831")
    gap = Label(root, text="", bg="#222831")
    gap.pack(anchor=N)
    main_frm = LabelFrame(root, bg="#393e46", borderwidth=0, padx=50)
    main_frm.pack(anchor=N)
    gap = Label(main_frm, text="", bg="#393e46")
    gap.pack(anchor=N)
    head = Label(main_frm, text="School Admin Software", font=("Freestyle Script", 20), bg="#393e46", fg="#eeeeee")
    head.pack(anchor=N)
    gap = Label(main_frm, text="", bg="#393e46")
    gap.pack(anchor=N)
    gap = Label(main_frm, text="", bg="#393e46")
    gap.pack(anchor=N)
    data_frm = LabelFrame(main_frm, bg="#393e46", borderwidth=0)
    data_frm.pack(anchor=N)
    name_frm = LabelFrame(data_frm, bg="#393e46", borderwidth=0)
    name_frm.pack(anchor=N)
    gap = Label(data_frm, text="", height=-1, bg="#393e46")
    gap.pack(anchor=N)
    pass_frm = LabelFrame(data_frm, bg="#393e46", borderwidth=0)
    pass_frm.pack(anchor=N)
    gap = Label(data_frm, text="", bg="#393e46")
    gap.pack(anchor=N)
    btn_frm = LabelFrame(data_frm, bg="#393e46", borderwidth=0)
    btn_frm.pack(anchor=N)
    name_entry = Entry(name_frm, text=value, borderwidth=0)
    name_entry.pack(ipadx=28.5)
    
    pass_entry = Entry(pass_frm, text=val, borderwidth=0)
    pass_entry.pack(ipadx=28.5)
    btn1 = Button(btn_frm, text="Log In", command=onclick, padx=70, bg="#32e0c4", fg="#eeeeee", borderwidth=0)
    btn1.pack()
    gap = Label(btn_frm, text="", bg="#393e46")
    gap.pack(anchor=N)
    gap = Label(btn_frm, text="---------------OR-----------------", bg="#393e46", fg="#eeeeee")
    gap.pack(anchor=N)
    gap = Label(btn_frm, text="", bg="#393e46")
    gap.pack(anchor=N)
    btn2 = Button(btn_frm, text='Forgot Password?', borderwidth=0, bg="#32e0c4", fg="#eeeeee")
    btn2.pack(anchor=N)

    gap = Label(main_frm, text="", bg="#393e46")
    gap.pack(anchor=N)
    
    gap = Label(root, text="", bg="#222831")
    gap.pack(anchor=N)


    data_frm1 = LabelFrame(root, bg="#393e46", borderwidth=0, padx=53.5)
    data_frm1.pack(anchor=N)
    gap = Label(data_frm1, text="", bg="#393e46")
    gap.pack(anchor=N)
    btn3 = Button(data_frm1, text="Don't have an account? Sign Up", fg="#ff2e63", borderwidth=0, bg="#393e46", command=new_acc_main)
    btn3.pack(anchor=N)   
    gap = Label(data_frm1, text="", bg="#393e46")
    gap.pack(anchor=N)
    gap = Label(root, text="", bg="#222831")
    gap.pack(anchor=N)
    lbl = Label(root, text="Get the app.", bg="#222831", fg="white")
    lbl.pack(anchor=N)
    img = ImageTk.PhotoImage(Image.open("app_base.png"))
    panel = Button(root, image = img, borderwidth=0)
    panel.pack(anchor=N) 
    gap = Label(root, text="", bg="#222831")
    gap.pack(anchor=N)
    rmcopyright = Label(root, text="Copyright © 2021 from RM SDC. All Rights Reserved. Powered by RM INC. and ADORABLE INC.", bg="grey", fg="black")
    rmcopyright.pack(side="bottom", fill="both")
    name_entry.bind("<Button-1>", some_callback)
    root.bind("<Return>", step_1)
    root.mainloop()

login_main()

The result is good-

The second window code, which doesnot works-

from tkinter import *
from PIL import ImageTk, Image
import os

def new_acc_main():
    def some_callback1(event):
        ent1.delete(0, END)
        return None

    def some_callback2(event):
        ent2.delete(0, END)
        return None

    def some_callback3(event):
        ent3.delete(0, END)
        return None

    def some_callback4(event):
        ent4.delete(0, END)
        return None

    def some_callback5(event):
        ent5.delete(0, END)
        return None

    def some_callback6(event):
        ent6.delete(0, END)
        return None

    def some_callback7(event):
        ent7.delete(0, END)
        return None

    

    root = Tk()

    gap = Label(root, text="", bg="#222831")
    gap.pack(anchor=N)


    root.config(bg="#222831")

    root.title("Sign Up")
    main_frm = LabelFrame(root, bg="#393e46", borderwidth=0, padx=20)
    main_frm.pack(anchor=N)
    data_frm = LabelFrame(main_frm, bg="#393e46", borderwidth=0)
    data_frm.pack(anchor=N)
    gap = Label(data_frm, text="", bg="#393e46")
    gap.pack(anchor=N)
    head_frm = LabelFrame(data_frm, bg="#393e46", borderwidth=0)
    head_frm.pack(anchor=N)
    gap = Label(data_frm, text="", bg="#393e46", borderwidth=0)
    gap.pack(anchor=N)

    head = Label(head_frm, text="School Admin System", font=("Freestyle Script", 20), bg="#393e46", fg="#eeeeee")
    head.pack(anchor=N)

    entries_frm = LabelFrame(data_frm, bg="#393e46", borderwidth=0)
    entries_frm.pack(anchor=N)

    ent1 = Entry(entries_frm)
    ent1.insert(0, "Employee ID")
    ent1.pack(anchor=N, ipadx=62.5)

    prt = LabelFrame(entries_frm, bg="#393e46", borderwidth=0)
    prt.pack(anchor=N)

    ent2 = Entry(prt)
    ent2.insert(0, "Username")
    ent2.grid(row=0, column=0)

    ent3 = Entry(prt)
    ent3.insert(0, "Password")
    ent3.grid(row=0, column=1)

    ent4 = Entry(prt)
    ent4.insert(0, "Designation")
    ent4.grid(row=1, column=0)

    ent5 = Entry(prt)
    ent5.insert(0, "Date of Birth(yy/mm/d)")
    ent5.grid(row=1, column=1)

    ent6 = Entry(prt)
    ent6.insert(0, "Email ID")
    ent6.grid(row=2, column=0)

    ent7 = Entry(prt)
    ent7.insert(0, "Phone No.")
    ent7.grid(row=2, column=1)

    gap = Label(data_frm, text="", bg="#393e46")
    gap.pack()

    btn_frm = LabelFrame(data_frm, bg="#393e46", borderwidth=0)
    btn_frm.pack(anchor=N)

    btn1 = Button(btn_frm, text="Sign Up", padx=101.5, bg="#32e0c4", fg="#eeeeee")
    btn1.pack(anchor=N)

    gap = Label(main_frm, text="", bg="#393e46")
    gap.pack(anchor=N)

    gap = Label(root, text="", bg="#222831")
    gap.pack(anchor=N)

    data_frm1 = LabelFrame(root, bg="#393e46", borderwidth=0, padx=16)
    data_frm1.pack(anchor=N)
    gap = Label(data_frm1, text="", bg="#393e46")
    gap.pack(anchor=N)
    btn2 = Button(data_frm1, text="Have an account? Log in", padx=62, borderwidth=0, bg="#393e46", fg="#ff2e63", command=root.destroy)
    btn2.pack(anchor=N)
    gap = Label(data_frm1, text="", bg="#393e46")
    gap.pack(anchor=N)

    gap = Label(root, text="", bg="#222831")
    gap.pack(anchor=N)
    lbl = Label(root, text="Get the app.", bg="#222831", fg="white")
    lbl.pack(anchor=N)
    img = ImageTk.PhotoImage(Image.open("app_base 1.png"))
    panel = Button(root, image = img, borderwidth=0)
    panel.pack(anchor=N) 
    gap = Label(root, text="", bg="#222831")
    gap.pack(anchor=N)

    rmcopyright = Label(root, text="Copyright © 2021 RM SDC. All Rights Reserved. Powered by RM INC. and ADORABLE INC.", bg="grey", fg="black")
    rmcopyright.pack(side="bottom", fill="both")
    ent1.bind("<Button-1>", some_callback1)
    ent2.bind("<Button-1>", some_callback2)
    ent3.bind("<Button-1>", some_callback3)
    ent4.bind("<Button-1>", some_callback4)
    ent5.bind("<Button-1>", some_callback5)
    ent6.bind("<Button-1>", some_callback6)
    ent7.bind("<Button-1>", some_callback7)
    root.mainloop()

The result is not good-
image

The error is as follows-

Please reply as earliest as possible in order I can go ahead with the project.
Thanks in advance.