conda报错-Collecting package metadata (current_repodata.json): failed

    Anaconda提供了在单机上执行Python / R数据科学和机器学习的最简单方法。有了anaconda帮助管理各种项目运行所需要的环境,就不用担心电脑上的python环境错综复杂带来的抓狂了。

问题描述

    用conda create –name my_virtual_name python=3.8,创建虚拟环境时,出现以下报错

C:\Users\XSF>conda create --name my_virtual_name python=3.8
Collecting package metadata (current_repodata.json): failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/current_repodata.json>
Elapsed: -

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.
'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64'

问题分析

从输出的描述分析来看,应该是源的问题。我们可以通过更改源或重置源来解决它。

Solution

有以下解决方案:

  • 1、重新安装Anaconda

    这种办法非常简单粗暴,常用。如果不删除虚拟环境中的文件,重新安装Anaconda不会影响已配置的虚拟环境。

  • 2、重置或者换源

恢复默认源:

conda config --remove-key channels

更改来源:
(清华来源)

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

(中国科学技术大学)

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/

参考

https://zhuanlan.zhihu.com/p/123188004[0]

conda相关命令

  • 创建虚拟环境
conda create --name my_virtual_name python=3.8
  • 激活虚拟环境
activate my_virtual_name

  • 退出虚拟环境
conda deactivate

  • 列出创建的虚拟环境
conda env list
  • 删除虚拟环境
conda remove --name my_virtual_name --all

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(1)
青葱年少的头像青葱年少普通用户
上一篇 2022年4月28日
下一篇 2022年5月6日

相关推荐