windows、linux更换pip源的方法

在用Python的时候,往往需要装很多库,默认的pip源是这样的:

https://files.pythonhosted.org/packages/........

国内访问的速度经常让人无法忍受

 

这时候可以将pip源更换为国内的源,具体方法如下:

1. 找到pip文件的位置,如不存在则新建

  • Windows系统:%appdata%/pip/pip.ini
  • Linux系统:~/.pip/pip.conf

2. 将默认的pip配置文件替换为以下内容:

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

 

此时就大功告成了,重新执行pip即可发现速度非常快,下载源也变成了tsinghua的

windows、linux更换pip源的方法_第1张图片

 

最后,附上几个常用的国内源

pip国内镜像源

阿里云 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/

你可能感兴趣的:(Python)