對于Python開發(fā)用戶來講沛申,PIP安裝軟件包是家常便飯。但國外的源下載速度實(shí)在太慢,浪費(fèi)時間野崇。而且經(jīng)常出現(xiàn)下載后安裝出錯問題袜蚕。所以把PIP安裝源替換成國內(nèi)鏡像糟把,可以大幅提升下載速度,還可以提高安裝成功率牲剃。
國內(nèi)源:
新版ubuntu要求使用https源遣疯,要注意。
清華:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中國科技大學(xué) https://pypi.mirrors.ustc.edu.cn/simple/
華中理工大學(xué):http://pypi.hustunique.com/
山東理工大學(xué):http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
臨時使用:
可以在使用pip的時候加參數(shù)-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider凿傅,這樣就會從清華這邊的鏡像去安裝pyspider庫缠犀。
永久修改,一勞永逸:
Linux下聪舒,修改 ~/.pip/pip.conf (沒有就創(chuàng)建一個文件夾及文件辨液。文件夾要加“.”,表示是隱藏文件夾)
內(nèi)容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com
windows下箱残,直接在user目錄中創(chuàng)建一個pip目錄滔迈,如:C:\Users\xx\pip,新建文件pip.ini。內(nèi)容同上亡鼠。