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'

问题分析

    从输出的描述分析,应该是源的问题。我们可以从换源或者重置源的办法解决。

解决办法

有以下解决办法:

  • 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

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
评论 23
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

维度攻城狮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值