出現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