Home > Software engineering >  AttributeError: module 'PIL.Image' has no attribute 'Open' (without using from t
AttributeError: module 'PIL.Image' has no attribute 'Open' (without using from t

Time:10-06

AttributeError: type object 'Image' has no attribute 'open'

I found an answer about my problem but still I cannot run the code and still python insists on showing

AttributeError: module 'PIL.Image' has no attribute 'Open'.

from tkinter import filedialog, Tk, Frame, Label, PhotoImage, Button
from PIL import ImageTk, Image
import tkinter as tk
from tkinter import messagebox
import json

and the code I want to run is:

        window1 = tk.Toplevel()
        window1.config(bg='lightgreen')
        window1.title("Form Calcualtion")
        window1.geometry("640x640")
        new_logo=Image.Open("formpic.png")
        r_new_logo=new_logo.resize((640,640),Image.ANTIALIAS)
        logo2 = ImageTk.PhotoImage(r_new_logo)
        windowlbl=tk.Label(window1,image=logo2).pack()

CodePudding user response:

I would rather make a comment because I am not sure about this but I can't make any comments yet. Please try open instead of Open and let me know if it helps...

  • Related