【问题标题】:AttributeError: module 'PIL.Image' has no attribute 'Open' (without using from tkinter import *)AttributeError:模块“PIL.Image”没有属性“Open”(不使用 from tkinter import *)
【发布时间】:2021-10-05 11:02:29
【问题描述】:

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

我找到了关于我的问题的答案,但我仍然无法运行代码,python 仍然坚持显示

AttributeError: 模块 'PIL.Image' 没有属性 '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

我要运行的代码是:

        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()

【问题讨论】:

  • 如果您发布您的堆栈跟踪信息会很有帮助,否则很难提供帮助。谢谢。
  • TYPO: Image.Open 应该是 Image.open small o
  • 是的,谢谢

标签: python tkinter


【解决方案1】:

我宁愿发表评论,因为我不确定这一点,但我还不能制作任何 cmets。请尝试打开而不是打开,如果有帮助,请告诉我...

【讨论】:

  • 是的,谢谢
  • 好!如果你能接受我的回答会很有帮助,下次我可以发表评论;)谢谢!
  • 有时长时间专注于这种情况会导致忽略小细节。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-11-18
  • 2017-03-21
  • 1970-01-01
  • 1970-01-01
  • 2019-04-13
  • 1970-01-01
  • 2018-02-03
相关资源
最近更新 更多