An HTTP error occurred when trying to retrieve this URL.(解决方案)

在通过vscode向服务器安装pytorch时,切换了清华源之后,遇到了下面的错误:
An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent, and a simple retry will get you on your way.
在这里插入图片描述
遇到此错误的时添加的清华源如下:

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 --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes

解决方案:
将添加的清华源地址中的https改为http,添加清华源如下:

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes

改为http后再运行pytorch安装命令就不会出现上面所提到的错误,如下图所示:
在这里插入图片描述
附:
清空源命令:

conda config --remove-key channels

猜你喜欢

转载自blog.csdn.net/thy0000/article/details/123563336