离线安装Pytorch

我安装的是无CUDA版的

1、进入清华镜像-找到 win64位的

https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/

2、这时候我们需要 安装两个东西

离线安装Pytorch

找到你电脑对应的版本配置 把这两个文件下载下来

3、在该文件目录下打开Anconda Prompt 

离线安装Pytorch离线安装Pytorch

 

4、之后进入python命令行进行验证

离线安装Pytorch

当我输入 import torchvision 时 系统报错,然后查资料我了解到torchvision在运行时要调用PIL模块,调用PIL模块的PILLOW_VERSION函数。但是PILLOW_VERSION在Pillow 7.0.0之后的版本被移除了,Pillow 7.0.0之后的版本使用__version__函数代替PILLOW_VERSION函数。

5、解决办法

根据报错的最后一行提示,打开function.py文件

我的路径是C:\Users\Administrator\anaconda3\lib\site-packages\torchvision\transforms\functional.py

进入这个文件后,用from PIL import Image, ImageOps, ImageEnhance, __version__ 替换文件中from PIL import Image, ImageOps, ImageEnhance,PILLOW_VERSION这句,最后保存即可。

6、验证

离线安装Pytorch

此时系统已经不报错了。