通常库PIL的连接步骤如下:连接到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 (most recent call last): File "C:\Python33\projects\PIL_IMAGETK\ImageTK_photoimage - копия.py", line 11, in openImg = PIL.Image.open(pathImg1) AttributeError: 'module' object has no attribute 'Image'