更换pip源,解决pip install安装包慢的问题

而pip是很强大的Python包安装工具,但是由于国外官方pypi经常被墙,导致不可用,所以最好是将使用的pip源更换一下,这样就能解决被墙导致的装不上库的问题。
网上有很多可用的源,例如
豆瓣:http://pypi.douban.com/simple/
清华:https://pypi.tuna.tsinghua.edu.cn/simple

1. 临时使用

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

2. 永久修改
linux下,修改 ~/.pip/pip.conf (没有就创建一个),内容如下:

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

参考:

https://www.cnblogs.com/mosson/p/7379854.html

http://blog.csdn.net/rytyy/article/details/78088682

原文地址:https://www.cnblogs.com/bymo/p/8378201.html