conda 切换为国内源【清华源与中科大源】

本文介绍如何通过配置conda使用清华大学及中国科学技术大学提供的国内镜像源,加速依赖包的安装过程。文中提供了详细的命令说明,包括添加镜像源、设置搜索时显示通道地址等操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

conda 切换为国内源【清华源与中科大源】

写在前面

最近,一直在学习机器学习相关的内容。在这个过程中,需要利用Anaconda配置虚拟环境运行示例程序,但是在利用conda安装一些依赖时,速度非常地感人,让打工人想哭。所以考虑切换conda的默认源,利用国内的镜像源提升下载速度。

conda 添加清华源

打开CMD终端窗口,输入下面的指令:

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

如果需要安装PyTorch,还需要添加PyTorch的镜像源:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

# 设置搜索时显示通道地址
conda config --set show_channel_urls yes

conda 添加中科大源

打开CMD终端窗口,输入下面的指令:

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/
# 设置搜索时显示通道地址
conda config --set show_channel_urls yes

切换默认源

删除添加的镜像源,恢复默认官方源:

conda config --remove-key channels

查看镜像源的优先权:

conda config --get channels
# 输出
--add channels 'defaults'   # lowest priority
--add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
--add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/'   # highest priority

End

参考博客:

  1. https://blog.youkuaiyun.com/ytusdc/article/details/89469161?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control

  2. https://www.cnblogs.com/lvchengda/p/12533040.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值