Anaconda配置国内镜像源

本文介绍了如何为conda和pip配置国内镜像源,以加快软件包的下载和安装速度。首先,通过命令行添加清华大学的conda镜像源,然后展示已添加的源,并说明如何删除特定源。接着,介绍了使用pip时临时和永久更改镜像源的方法,包括阿里云等国内常用镜像地址。通过这些步骤,可以显著提高在Windows和Linux系统上的包管理效率。

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

1. 为conda配置(清华)镜像源

使用conda进行安装时,访问的是国外的网络,所以下载和安装包时会特别慢。我们需要更换到国内镜像源地址,这里我更换到国内的清华大学地址。(永久添加镜像)

Windows和Linux 对于conda修改镜像源的方法一样

1.添加清华镜像:

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

2.显示添加的源

conda config --show channels

3.删除指定源

conda config --remove channels 源名称或链接 

2. 为pip配置国内镜像源

2.1 配置pip镜像源(临时修改的方法)

可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple

例如:

pip install numpy -i https://mirrors.aliyun.com/pypi/simple/

国内常用源镜像地址:

清华:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:https://mirrors.aliyun.com/pypi/simple/

中国科技大学: https://pypi.mirrors.ustc.edu.cn/simple/

华中理工大学:https://pypi.hustunique.com/

山东理工大学:https://pypi.sdutlinux.org/ 

豆瓣:https://pypi.douban.com/simple/

2.2配置pip镜像源(永久有效)

1.Windows系统

windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容如下:

[global]  
index-url = https://mirrors.aliyun.com/pypi/simple/

2.Linux系统

mkdir ~/.pip
cd ~/.pip
vim pip.conf

内容和上面的一样

[global]  
index-url = https://mirrors.aliyun.com/pypi/simple/

3.下载测试

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值