[英]'module' object is not callable while opening a image in python using PIL
[英]Attribute Error while using Image Module from PIL library in Python 3
我正在构建一个简单的 python 3 程序来打开和调整图像大小。 我正在使用 Pycharm。 我从 PIL 导入 Image 并尝试运行以下命令:
image1 = Image.open('<file location>')
但解释器显示属性错误,类型 Image 没有打开属性。
我的程序是:
from PIL import Image
from tkinter import *
root = Tk()
image2 = Image.open('hp png.png')
hp_image2 = Label(root , image = image2)
hp_image2.pack(fill = BOTH)
root.mainloop()
output 是:在此处输入图像描述
从 tkinter 的导入正在替换从 PIL 的导入。 考虑更换
from tkinter import *
和
import tkinter as tk
并使用新的导入更新代码的 rest。
尝试这个:
import PIL.Image
from tkinter import Tk
image2 = PIL.Image.open('hp png.png')
希望它会奏效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.