zl程序教程

您现在的位置是:首页 >  其他

当前栏目

完美解决导入from PIL import image出现错误的问题

错误导入 解决 出现 from 完美 Image import
2023-09-14 09:09:14 时间

1)运行此命令:

import sys
from PIL import Image
sys.modules['Image'] = Image

2)在笔记本中运行以下两行,以确保它们正确指向同一目录(如果不是因为你的PIL旧库弄乱了Pillow库)

from PIL import Image
print(Image.__file__)

import Image
print(Image.__file__)

3)如果它正常工作并且两个导入打印指向同一个python3目录,那么继续.

如果不,转到您的操作系统控制台和您的conda环境(确保您在所需的conda环境中工作):

conda uninstall PIL
conda uninstall Pillow
conda install Pillow

您现在应该已经成功安装了Pillow的所有库,并解决了PIL的任何问题.