由於國外的pip源總是由於各種原因不能被訪問或者網速過慢,而造成的timeout錯誤
解決方法是修改pip的配置文件(如果沒有配置文件在相應的地方新建,配置文件的路徑和名字參考這里),設置安裝包時候訪問的鏡像,將其改為國內的鏡像
然后設置timeout的時間長一些
例如配置文件設置如下:
配置文件地址:
C:\ProgramData\pip\pip.ini
Windows 7 and later the file is hidden, but writeable at C:\ProgramData\pip\pip.ini
配置文件內容:
[global]
timeout = 60
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com
[install]
use-mirrors = true
mirrors = http://pypi.douban.com
trusted-host = pypi.douban.com
如何確認自己成功修改了pip安裝包時候使用的源鏡像,只要重現使用pip命令,查看其下載地址為douban就說明設置成功了
參考:
https://segmentfault.com/q/1010000000162410
