import torch 成功
但是import torchvision,报错
DLL:找不到模块
网上说可能是numpy版本的问题,pillow版本的问题,按照方法更改后都没用。
看到的另一个原因:可能是torch和torchvision 版本不对应
解决方法:https://pytorch.org/get-started/locally/ 打开官网,选择你相应的配置,我是CPU版本。
图片最后一行给出了怎么安装的代码。
pip3 install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
打开Ananconda prompt 进入pytorch环境,卸载torch 和torchvision
pip uninstall torchvision
pip uninstall torch
安装之前加上清华源下载更快
添加清华镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
#添加清华镜像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
再重新使用官网给出两者版本一致的的代码:
pip3 install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
就安装成功了。import torchvision验证,就不报错了。