anaconda加载torch/torchvision库出现CondaHTTPError/An HTTP error问题解决办法

An HTTP error 问题

conda httperror http none none for url none Anaconda更新失败
在conda安装好之后,默认的镜像是官方的,由于官网的镜像在境外,访问太慢或者不能访问,为了能够加快访问的速度,这里选择了清华的的镜像。但是之前搜索的镜像主要是下面,实际操作时还是会出现An HTTP error occured when trying to retrieve this URL.HTTP errors are often intermittent;

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

在用户home目录下,找到 .condarc 文件,删掉channels下面的 -defaults一行,替换里面的链接:

channels:
  - defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

即可添加 Anaconda Python 免费仓库;
然后在jupyter中进行检查:

imprt torch
import torchvision
#没有报错,即说明加包成功

你可能感兴趣的:(CV,Python基础)