【Python】Anaconda以及Pip配置清华镜像源

【Python】Anaconda以及Pip配置清华镜像源


前言

提示:

最近换了新电脑,在使用Anaconda安装Python包时,系统会自动从默认源下载安装包,但是由于网络访问限制或网络连接速度较慢等原因,会导致安装失败或安装速度较慢。
因此,为了提高安装速度和稳定性,一些用户选择使用国内的镜像源,如清华镜像源。配置清华镜像源可以让用户从国内的服务器上下载Python包,这可以加快下载速度,并减少由于网络访问限制导致的下载失败等问题。


一、Conda配置清华镜像源

1. 查看镜像源

conda config --show channels

2. 删除添加源,恢复默认源

conda config --remove-key channels

3. 添加清华镜像源

#添加镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
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/r
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2

#终端显示包从哪个channel下载,以及下载地址是什么
conda config --set show_channel_urls yes

二、Pip配置清华镜像源

1. 临时使用清华镜像源

代码如下(示例):

# some-package代表你需要安装的包
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package

下面这种方式也是一样的

pip install some-package -i https://pypi.tuna.tsinghua.edu.cn/simple

2.永久配置

代码如下(示例):

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

三、国内常用的镜像源

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

清华大学开源软件镜像站:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云开源镜像站:https://mirrors.aliyun.com/pypi/simple/
豆瓣:https://pypi.douban.com/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/


  • 56
    点赞
  • 317
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

HuangZouZou

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值