Python pip换源所有方法

你好,我是悦创。

我接下来,把所有 Python pip 换源的方法,都整理下来。

第一种方法

  1. 打开 appdata 文件夹,在资源管理器的地址栏输入 %appdata% 后回车:

在这里插入图片描述
2. 新建一个 pip 文件夹,在 pip 文件夹里面新建一个配置文件 pip.ini

在这里插入图片描述
3. 在配置文件中输入如下内容后保存即可:

[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn

再次使用 pip,即会使用新源。

一些常用的国内源:

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

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

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

  • 豆瓣:http://pypi.douban.com/simple

第二种方法

在这里插入图片描述

第三种方法

pip10.0.0 开始,有个 config 子命令可用来改配置,无需关心不同操作系统下配置文件路径。

详见讨论:https://link.zhihu.com/?target=https%3A//github.com/pypa/pip/issues/1736

实际使用例子:

# 阿里源
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/

# 豆瓣源
pip config set global.index-url https://pypi.douban.com/simple

# 阿里云 http://mirrors.aliyun.com/pypi/simple/
# 科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
# 豆瓣(douban) http://pypi.douban.com/simple/
# 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
# 中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

参考

  1. 数据分析的环境不会搭?看这里准没错!:https://www.aiyc.top/772.html
  2. Linux下pip使用国内源:https://www.aiyc.top/153.html
  3. Windows下更换pip源为清华源:https://www.aiyc.top/1657.html
  • 25
    点赞
  • 102
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

AI悦创|编程1v1

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

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

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

打赏作者

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

抵扣说明:

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

余额充值