將pip源更換到國內鏡像


將pip源更換到國內鏡像
用pip管理工具安裝庫文件時,默認使用國外的源文件,因此在國內的下載速度會比較慢,可能只有50KB/s。幸好,國內的一些頂級科研機構已經給我們准備好了各種鏡像,下載速度可達2MB/s。
其中,比較常用的國內鏡像包括:

(1)阿里雲 http://mirrors.aliyun.com/pypi/simple/
(2)豆瓣http://pypi.douban.com/simple/
(3)清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/
(4)中國科學技術大學 http://pypi.mirrors.ustc.edu.cn/simple/
(5)華中科技大學http://pypi.hustunique.com/

 

方式一:臨時使用國內pypi鏡像安裝

pip install -i http://pypi.douban.com/simple/ numpy
pip install -i http://pypi.douban.com/simple/--trusted-host pypi.douban.com  #此參數“--trusted-host”表示信任,如果上一個提示不受信任,就使用這個

方式二:永久使用國內pypi鏡像安裝

有沒有什么辦法,可以像往常一樣,只使用pip install <包名>,但是直接使用指定的鏡像源呢?

windows環境:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

 

 centOS7環境:

(pd_test) [root@67 ~]# pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
Writing to /root/.config/pip/pip.conf

 


免責聲明!

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



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