Miniconda config channels的查看、删除、添加

@创建于:2025.12.13
@修改于:2025.12.13

1. 背景

miniconda里面安装pandas的时候报错

Collecting package metadata (current_repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
Solving environment: unsuccessful attempt using repodata from current_repodata.json, retrying with next repodata source.
Collecting package metadata (repodata.json): /

在这里插入图片描述
若长时间卡在此步骤,可尝试:
1、清除conda缓存 conda clean --all ,然后重试。
2、一次性使用清华源conda install pandas==2.2.3 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
3、使用pip安装(更简单快速)pip install pandas==2.2.3 -i https://pypi.tuna.tsinghua.edu.cn/simple

2. 配置文件.condarc

.condarc是conda 应用程序的配置文件,在用户家目录(windows:C:\users\username\),用于管理镜像源。如果不存在,则打开conda的,执行一下:

conda config --show channels

3 show channels 的工作机制

很多人以为列表第一个 channel 优先级最高,其实是反的!Conda 默认采用 “后进先出” 的查找策略:

channels:
  - A
  - B
  - C

查找顺序是:A → B → C

4. 初始配置

对.condarc进行初始配置,是装完 Miniconda 做的第一件事,这个很重要。

# 添加清华镜像源(注意顺序!)
conda config --add channels defaults

conda config --add channels conda-forge

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

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 --set channel_priority strict

# 验证是否生效
conda config --show channels

# 显示镜像源站点
conda config --set show_channel_urls yes

.condarc中的内容如下

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - conda-forge
  - defaults
channel_priority: strict
show_channel_urls: true

推荐组合:

  • 清华源:速度快,更新及时;
  • conda-forge:社区维护,包最全,很多前沿库只在这里有;
  • defaults:作为最终保障。

5. 参考连接

Miniconda config show channels查看当前源配置

Conda Channels镜像源(通道)配置

【Python】conda镜像配置,.condarc文件详解,channel镜像

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值