【发布时间】:2014-02-10 08:52:59
【问题描述】:
通常库PIL的连接方式如下:
from PIL import ImageTk, Image
我想这样连接:
import PIL
但我的版本不起作用。代码如下:
import os, sys
import tkinter
import PIL
main = tkinter.Tk()
catalogImg1 = 'imgs'
nameImg1 = 'n.jpg'
pathImg1 = os.path.join(catalogImg1, nameImg1)
openImg = PIL.Image.open(pathImg1)
renderImg = PIL.ImageTk.PhotoImage(openImg)
tkinter.Label(main, image=renderImg).pack()
main.mainloop()
错误信息是:
Traceback(最近一次调用最后一次):文件 “C:\Python33\projects\PIL_IMAGETK\ImageTK_photoimage - копия.py”,行 11、在 openImg = PIL.Image.open(pathImg1) AttributeError: 'module' object has no attribute 'Image'
【问题讨论】:
标签: python python-3.x tkinter python-imaging-library