已安装 pytorch 和 torchvision 的版本可以对应,但是在导入时,出现error:
torchvision ImportError: cannot import name ‘PILLOW_VERSION’ from ‘PIL’
这是因为torchvision的文件中使用的 ‘PILLOW_VERSION’在已安装的pillow中不存在。虚拟环境默认安装的pillow版本为7.0.0,此版本的pillow已经移除了’PILLOW_VERSION’。需要将pillow安装至更低点的版本,如pillow6.1
安装步骤:
conda uninstall pillow
conda install==6.1
卸载pillow的过程中会自动卸载torchvision,重新根据已有的pytorch版本安装即可。
参考:
https://github.com/pytorch/vision/issues/1712
https://blog.csdn.net/weixin_40512640/article/details/103897335
https://blog.csdn.net/wei2013303336/article/details/103993421