出现socket.timeout: The read operation timed out 错误的时候,多是pip源不稳定,改改试试看! python
常常在使用Python的时候须要安装各类模块,而pip是很强大的模块安装工具,可是因为国外官方pypi常常被墙,致使不可用,因此咱们最好是将本身使用的pip源更换一下,这样就能解决被墙致使的装不上库的烦恼。linux
网上有不少可用的源,例如豆瓣:http://pypi.douban.com/simple/windows
清华:https://pypi.tuna.tsinghua.edu.cn/simplesocket
最近使用得比较多而且比较顺手的是清华大学的pip源,它是官网pypi的镜像,每隔5分钟同步一次,地址为 https://pypi.tuna.tsinghua.edu.cn/simple工具
临时使用:url
能够在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simplespa
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gevent,这样就会从清华这边的镜像去安装gevent库。.net
永久修改,一劳永逸:ip
Linux下,修改 ~/.pip/pip.conf (没有就建立一个), 修改 index-url至tuna,内容以下:get
[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