anaconda3 换国内源

这篇博客提供了两种方法来更换Anaconda的默认源,分别是切换到清华大学和中国科学技术大学的镜像源。通过运行提供的cmd脚本,可以将conda配置文件更新为这两个国内镜像,从而加速包的下载和更新速度。

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

anaconda3 换国内源

一、换清华源 conda_qh.cmd

@echo off
echo 换清华源 conda_qh.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/
rem # 设置搜索时显示通道地址
conda config --set show_channel_urls true

 

 

二、 换中科大源 conda_zkd.cmd

@echo off
eoch rem 换中科大源 conda_zkd.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 true

 

 

 

 

### 更改 Anaconda 配置以使用国内镜像源 #### 使用 `conda config` 命令配置清华镜像源 为了提高下载速度并优化体验,可以更改 Anaconda 的默认源至国内镜像。具体操作如下: ```bash conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ conda config --set show_channel_urls yes ``` 上述命令会向 conda 添加清华大学开源软件镜像站作为新的 channel 并设置显示渠道 URL[^1]。 #### 创建或编辑 `.condarc` 文件手动指定镜像源 另一种方法是直接编辑或新建`.condarc`文件来定义所需的镜像源。此文件通常位于用户的 home 目录下(例如 Windows 上为 `%USERPROFILE%\.condarc`, Linux 和 macOS 上则是 `~/.condarc`)。内容应类似于下面这样: ```yaml channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ show_channel_urls: true default_channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main custom_channels: pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud ``` 这段 YAML 格式的配置指定了多个可用的包仓库位置以及是否展示具体的下载链接[^2]。 #### 设置 Python 包安装工具 Pip 使用阿里云镜像源 对于通过 pip 安装 python 库的情况,则需调整 pip 的全局配置使得它指向更快捷稳定的国内站点。这可以通过创建或修改位于特定路径下的配置文件实现: - 对于 Windows 用户来说是在 `%APPDATA%\pip\pip.ini` - 而 Unix 类系统 (Linux, MacOS) 则通常是 `$HOME/.config/pip/pip.conf` 这些文件的内容应该形如: ```ini [global] timeout = 6000 index-url = https://mirrors.aliyun.com/pypi/simple/ trusted-host = mirrors.aliyun.com ``` 以上参数分别代表超时时间和索引网址还有信任主机列表[^3]。 完成上述任一步骤之后重启终端窗口使新设定生效即可享受更快速度!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值