AttributeError:模块'PIL.ImageFile'没有属性'ImageFile'
我已经使用命令“ pip install pillow”安装了PIL
From PIL import Image
sourceFileName = "source.png"
Avatar= Image.open(sourceFileName)
File "d:/sourcecode/test.py", line 3, in <module>
Avatar= Image.open(sourceFileName)
File "C:\**\Python37-32\lib\site-packages\PIL\Image.py", line 2663, in open
Preinit()
File "C:\**\Python37-32\lib\site-packages\PIL\Image.py", line 381, in preinit
From . import BmpImagePlugin
File "C:\**\Python37-32\lib\site-packages\PIL\BmpImagePlugin.py", line 61, in <module>
Class BmpImageFile(ImageFile.ImageFile):
AttributeError: module 'PIL.ImageFile' has no attribute 'ImageFile'
答案 0 :(得分:0)
您可以按以下方式导入ImageFile:
from PIL import Image, ImageFile
sourceFileName = "source.png"
avatar = Image.open(sourceFileName)