Conda国内镜像源及配置过程

 更新时间:2025年08月11日 14:08:36   作者:AI手记叨叨  
文章介绍Conda镜像源使用方法,涵盖临时指定单个/多个源、永久配置及恢复默认设置,同时说明main(官方稳定)、free(逐渐弃用)、conda-forge(社区更新快)等仓库的区别与适用场景

一、Conda国内镜像源

# 清华大学
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/cloud/conda-forge/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

# 中国科学技术大学
https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/

# 北京外国语大学
https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/
https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/
https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/

# 南京大学
https://mirror.nju.edu.cn/anaconda/pkgs/main/
https://mirror.nju.edu.cn/anaconda/pkgs/free/

# 华为云
https://mirrors.huaweicloud.com/anaconda/pkgs/main/
https://mirrors.huaweicloud.com/anaconda/pkgs/free/
https://mirrors.huaweicloud.com/anaconda/cloud/conda-forge/

# 腾讯云
https://mirrors.cloud.tencent.com/anaconda/pkgs/main/
https://mirrors.cloud.tencent.com/anaconda/pkgs/free/
https://mirrors.cloud.tencent.com/anaconda/cloud/conda-forge/ 

# 阿里
https://mirrors.aliyun.com/anaconda/pkgs/main/
https://mirrors.aliyun.com/anaconda/pkgs/free/
https://mirrors.aliyun.com/anaconda/cloud/conda-forge/

# 上海交通大学
https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/

二、Conda临时使用镜像源

指定单个源

  • 直接使用镜像站URL
conda install -c https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/ package_name
  • 或者使用镜像源的别名
conda install -c conda-forge package_name

临时指定多个源

  • Conda按优先级从左到右依次搜索-c参数的源,最后搜索全局配置的源(~/.condarc 中的 channels)
conda install -c https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/ -c defaults package_name

创建环境时临时指定源

conda create -n my_env -c https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/ python=3.9

避免搜索远程源

  • 如果本地已有缓存包,强制使用本地包
conda install --use-local package_name

三、Conda永久配置镜像源

通过conda命令配置

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/conda-forge/
conda config --set show_channel_urls yes

直接修改.condarc文件

sudo vim ~/.condarc
  • 在用户目录下创建或修改.condarc文件
channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - 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

恢复默认配置

  • 删除 ~/.condarc 文件(简单粗暴)
rm ~/.condarc
  • 或者手动移除 channels
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

四、仓库说明

main、free和conda-forge是不同的软件包仓库,它们提供不同类型的Python包和环境依赖。

main(主仓库)

来源:

  • 由Anaconda官方维护

内容:

  • 包含Anaconda官方认证的、经过严格测试的稳定版本软件包。
  • 通常是较为成熟的软件,更新频率较低,但稳定性高。

用途:

  • 适合生产环境或需要稳定版本的场景。

free(免费仓库)

来源:

  • Anaconda 官方维护,但已逐渐被弃用。

内容:

  • 早期Anaconda将部分包标记为free(开源免费)和non-free(商业许可)。
  • 现在大多数包已迁移到 main 或 conda-forge,因此 free 仓库中的包较少。

注意:新版本Conda可能不再默认使用free,建议优先使用main或conda-forge。

conda-forge(社区仓库)

来源:

  • 由社区维护(非官方)。

内容:

  • 包含大量最新的开源软件包,更新频繁,版本较新。
  • 许多前沿工具(如机器学习库)会优先发布到 conda-forge。

特点:

  • 包数量远超 main,但稳定性可能略低(未经 Anaconda 官方全面测试)。
  • 与 main 仓库可能存在依赖冲突,建议单独使用或通过环境管理隔离。

用途:

  • 适合开发、测试或需要最新版本的场景。

其他常见库

  • msys2:提供 Windows 系统的工具链(如 GCC、Git)。
  • pytorch:PyTorch 官方维护的仓库。
  • tensorflow:TensorFlow 官方仓库(Google 维护)
  • nvidia:NVIDIA GPU 相关工具(CUDA、cuDNN 等)
  • fastai:Fast.ai 相关的深度学习工具
  • bioconda:生物信息学领域的专用包。
  • ioam:地理空间数据处理(如 geopandas 的早期版本)
  • plotly:Plotly 交互式可视化工具。
  • omnia:分子动力学模拟工具(如 OpenMM)。
  • r:R语言及其科学计算包。

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • django+celery+RabbitMQ自定义多个消息队列的实现

    django+celery+RabbitMQ自定义多个消息队列的实现

    本文主要介绍了django+celery+RabbitMQ自定义多个消息队列的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2023-02-02
  • Python中logging实例讲解

    Python中logging实例讲解

    在本篇文章里小编给大家分享的是关于Python中logging的详细介绍内容,有兴趣的朋友们跟着学习下。
    2019-01-01
  • python opencv实现图像配准与比较

    python opencv实现图像配准与比较

    这篇文章主要为大家详细介绍了python opencv实现图像配准与比较,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2021-02-02
  • 图解Python中深浅copy(通俗易懂)

    图解Python中深浅copy(通俗易懂)

    这篇文章主要介绍了图解Python中深浅copy(通俗易懂),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-09-09
  • Tortoise-orm信号实现及使用场景源码详解

    Tortoise-orm信号实现及使用场景源码详解

    这篇文章主要为大家介绍了Tortoise-orm信号实现及使用场景源码详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-03-03
  • python with语句的原理与用法详解

    python with语句的原理与用法详解

    这篇文章主要介绍了python with语句的原理与用法,结合实例形式详细分析了python with语句基本概念、原理、用法及操作注意事项,需要的朋友可以参考下
    2020-03-03
  • 自学python的建议和周期预算

    自学python的建议和周期预算

    在本篇文章中小编给大家分享了关于自学python的建议和周期预算,有兴趣的朋友们可以学习参考下。
    2019-01-01
  • Python实现8个概率分布公式的方法详解

    Python实现8个概率分布公式的方法详解

    在本文中,我们将介绍一些常见的分布(均匀分布、高斯分布、对数正态分布等)并通过Python代码进行可视化以直观地显示它们,感兴趣的可以学习一下
    2022-05-05
  • django-rest-framework解析请求参数过程详解

    django-rest-framework解析请求参数过程详解

    这篇文章主要介绍了django-rest-framework解析请求参数过程详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2019-07-07
  • 简单示例解析python爬虫IP的使用(小白篇)

    简单示例解析python爬虫IP的使用(小白篇)

    这篇文章主要为大家通过简单示例解析python爬虫IP的使用介绍,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-06-06

最新评论