python-----pip安裝源選擇(親測有效)


Python使用pip方法安裝第三方包時,需要從 https://pypi.org/ 資源庫中下載,但是會面臨下載速度慢,甚至無法下載的尷尬。

使用國內鏡像自然是個好方法:

清華大學: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 參數來指定鏡像地址,例如:

使用清華鏡像源安裝 numpy 包:pip3 install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple

永久生效需要做下配置:

linux:在用戶目錄下新建.pip/pip.conf,並編輯

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple 

[install]

trusted-host = https://pypi.tuna.tsinghua.edu.cn

 

windows:在用戶目錄下新建pip.ini,並編輯內容同linux

比如我的:C:\Users\Administrator\AppData\pip\pip.ini

內容同linux:

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple 

[install]

trusted-host = https://pypi.tuna.tsinghua.edu.cn

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM