解决pytorch指令安装时Could not find a version that satisfies the requirement xxx (from versions: none)

报错内容

Could not find a version that satisfies the requirement  xxx  (from versions: none)

报错原因

1 python版本与当前的pytorch版本不兼容
2 anaconda内的包未更新
3 镜像源问题(或网络问题)

解决方案

进入torch的wheel下载网站https://download.pytorch.org/whl/torch_stable.html
根据自己电脑的CUDA版本下载对应的torch和torchversion至同一文件夹,文件夹位置没有要求,记住先下载torch。
例如我是win10,安装的CUDA版本为10.1,python版本为3.8,选择如下whl下载。
解决pytorch指令安装时Could not find a version that satisfies the requirement xxx (from versions: none)_第1张图片与此同时,去pytorch官网查看当前所下载的torch版本对应的torchversion版本是什么,如下。这里官网显示的是torch1.9.0下对应的torchversion版本。
解决pytorch指令安装时Could not find a version that satisfies the requirement xxx (from versions: none)_第2张图片
依旧以上面我下载的版本为例,我下载的torch版本为1.8.1,那么对应的torchversion版本应选择如下
解决pytorch指令安装时Could not find a version that satisfies the requirement xxx (from versions: none)_第3张图片
之后进入这两个文件所在的文件夹路径内(注意要进入所创建的虚拟环境下下载),在终端下执行如下命令

pip install torch-1.8.1+cu101-cp38-cp38-win_amd64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install torchvision-0.9.1+cu101-cp38-cp38-win_amd64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple/

切记版本一定要对应好!

你可能感兴趣的:(报错解决,python,anaconda,pytorch)