1. 程式人生 > >PIP源使用國內映象,提升下載速度和安裝成功率

PIP源使用國內映象,提升下載速度和安裝成功率

國內源(新版ubuntu要求使用https源,要注意。):
清華:https://pypi.tuna.tsinghua.edu.cn/simple
阿里雲:http://mirrors.aliyun.com/pypi/simple/
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣:http://pypi.douban.com/simple/
還有一些別的沒有列出。
 
臨時使用:
可以在使用pip的時候加引數-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,這樣就會從清華這邊的映象去安裝pyspider庫。
 
永久修改,一勞永逸:
Linux下,修改 ~/.pip/pip.conf (沒有就建立一個資料夾及檔案。資料夾要加“.”,表示是隱藏資料夾)

內容如下:

[global]  
index-url = https://pypi.tuna.tsinghua.edu.cn/simple  
[install]  
trusted-host=mirrors.aliyun.com  
#timeout = 150 # 超時時間設定(單位為s),一般可以設定的長一些
windows下,直接在user目錄中建立一個pip目錄,如:C:\Users\xx\pip,新建檔案pip.ini。內容同上。