常常在使用python的时候须要安装各类模块,而pip是很强大的模块安装工具,可是因为国外官方pypi常常被墙,致使不可用,因此咱们最好是将本身使用的pip源更换一下,这样就能解决被墙致使的装不上库的烦恼。python
网上有不少可用的源,例如linux
豆瓣:http://pypi.douban.com/simple/ 清华:https://pypi.tuna.tsinghua.edu.cn/simple
最近使用得比较多而且比较顺手的是清华大学的pip源,它是官网pypi的镜像,每隔5分钟同步一次,地址为windows
清华大学的pip源:https://pypi.tuna.tsinghua.edu.cn/simple
临时使用:工具
能够在使用pip的时候加参数url
-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:code
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gevent
这样就会从清华这边的镜像去安装gevent库。ip
linux下,修改 ~/.pip/pip.conf (没有就建立一个), 修改 index-url至tuna,内容以下:同步
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple
windows下,直接在user目录中建立一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容以下pip
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple