likes
comments
collection
share

Python pip换源所有方法

作者站长头像
站长
· 阅读数 16

你好,我是悦创。

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

第一种方法

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

Python pip换源所有方法 2. 新建一个 pip 文件夹,在 pip 文件夹里面新建一个配置文件 pip.ini

Python pip换源所有方法 3. 在配置文件中输入如下内容后保存即可:

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

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

一些常用的国内源:

第二种方法

Python pip换源所有方法

第三种方法

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

详见讨论:link.zhihu.com/?target=htt…

实际使用例子:

# 阿里源
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. 数据分析的环境不会搭?看这里准没错!:www.aiyc.top/772.html
  2. Linux下pip使用国内源:www.aiyc.top/153.html
  3. Windows下更换pip源为清华源:www.aiyc.top/1657.html