通過將pip的源更換為國內源,來提高下載速度,這也將成為今后學習過程下載Python包的基礎,建議前期一定要完成!
知名的國內源
清華:https://pypi.tuna.tsinghua.edu.cn/simple
阿里雲:http://mirrors.aliyun.com/pypi/simple/
中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
華中理工大學:http://pypi.hustunique.com/
山東理工大學:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
需要注意的是新版的ubuntu要求使用http源。
使用方法
臨時修改
使用pip install的 -i 命令進行設置,格式如下:
-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider
永久修改
通過編輯pip的配置文件進行設置,方法如下:
在linux中,修改 ~/.pip/pip.config(如果沒有就自行創建,格式和前面的必須完全一致)。
添加內容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com
添加其他源,格式與上面的類似依次類推即可。