Python 更换国内pip源

已知的几个访问速度比较快的pip源:

豆瓣:http://pypi.douban.com/simple/
中科大:https://pypi.mirrors.ustc.edu.cn/simple/
清华:https://pypi.tuna.tsinghua.edu.cn/simple

一次性更换pip源:

可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:pip install xlwt -i https://pypi.tuna.tsinghua.edu.cn/simple
这样就会从清华的镜像去安装xlwt库。

永久修改pip源:

Linux:

修改 sudo vim~/.pip/pip.conf(没有就创建一个), 修改 index-url 为国内镜像地址,内容如下:

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

Windows:

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

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

(方法来自于互联网)

你可能感兴趣的:(Python 更换国内pip源)