解决“Could not find a version that satisfies the requirement torch...”问题

问题描述

今天在跑实验创建虚拟环境deepsort配置Pytorch的时候,首先创建了虚拟环境,但是没有指定Python版本,按照网上博客的顺序执行了该指令

pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html

然后出现了报错

Collecting torch==1.6.0+cu101
  Could not find a version that satisfies the requirement torch==1.6.0+cu101 (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2, 0.1.6.post17, 0.1.6.post20, 0.1.6.post22, 0.1.7.post2, 0.1.8.post1, 0.1.9.post1, 0.1.9.post2, 0.1.10.post1, 0.1.10.post2, 0.1.11.post4, 0.1.11.post5, 0.1.12.post1, 0.1.12.post2, 0.2.0.post1, 0.2.0.post2, 0.2.0.post3, 0.3.0, 0.3.0.post2, 0.3.0.post3, 0.3.0.post4, 0.3.1, 0.4.0, 0.4.1, 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.2.0+cpu, 1.2.0+cu92, 1.3.0, 1.3.0+cpu, 1.3.0+cu100, 1.3.0+cu92, 1.3.1, 1.3.1+cpu, 1.3.1+cu100, 1.3.1+cu92, 1.4.0, 1.4.0+cpu, 1.4.0+cu100, 1.4.0+cu92, 1.5.0+cpu, 1.5.0+cu92)
No matching distribution found for torch==1.6.0+cu101

问题分析

本来通过网上博客的解决方法,给的建议是直接去Pytorch官网下载whl文件在本地安装,但是安装过程还是出现报错

torch-1.6.0+cu101-cp37-cp37m-linux_x86_64.whl is not a supported wheel on this platform.

提示该文件本平台不支持,想到可能是在创建虚拟环境的时候没有指定Python版本

解决方法

删除原虚拟环境

conda remove -n deepsort --all

再次创建虚拟环境是指定Python版本

conda create -n deepsort python=3.7

重命名虚拟环境

虚拟环境是没有重命名功能的,只能先克隆一份再把原有的虚拟环境删除

# 克隆一份新环境
conda create -n new_envs --clone old_envs

# 删除老环境
conda remove -n old_envs --all

参考博客

conda创建、查看、删除虚拟环境

你可能感兴趣的:(Python,debug,python,anaconda,pytorch)