(1)在jupyter notebook中使用命令行安装Pillow模块;
pip install Pillow
(2)安装torchvison模块;
pip install torchvision
(3)在python环境中导入torchvision的时候,出现了以下错误:
ImportError: cannot import name 'PILLOW_VERSION' from 'PIL'
报错解释:torchvision模块在运行时要调用PIL模块的PILLOW_VERSION函数,但PILLOW_VERSION在Pillow 7.0.0之后的版本被移除了,Pillow 7.0.0之后的版本使用__version__函数代替PILLOW_VERSION函数。
解决方法:
①(对我没用,但是有一部分友友成功解决)写在Pillow模块,重现安装7.0.0之前的版本;
pip uninstall Pillow
pip install Pillow==6.2.2
②根据报错的最后一行提示,打开function.py文件,如下图所示:
接着,使用from PIL import Image, ImageOps, ImageEnhance, __version__ 替换文件中from PIL import Image, ImageOps, ImageEnhance,PILLOW_VERSION,最后保存即可。
成功展示: