1. 程式人生 > 其它 >更換國內映象源進行pip安裝

更換國內映象源進行pip安裝

Linux中當我們需要安裝某個模組時(比如tensorflow2.0.0),常見有三種方法:
  1. pip install tensorflow==2.0.0
  2. pip install https://pypi.douban.com/simple tensorflow==2.0.0
  3. pip install -i https://pypi.douban.com/simple --trusted-host pypi.douban.com tensorflow==2.0.0

第一種是最為基礎簡單的使用國外源安裝,很簡潔方便。但下載相對國內源緩慢,中途容易退出或者丟包,所以安裝大模組時使用較少。

第二種和第三種是我經常使用的,他們的區別就在於設定--trusted-host pypi.douban.com信任該映象源。

當使用第二種安裝遇到 ERROR: Cannot determine archive format of :XXXXXXXXXX 這種錯誤時,改為第三種即可。

國內其他映象源:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn 模組名 //清華大學
pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com/pypi 模組名       //阿里雲
pip install -i 
http://pypi.douban.com/simple --trusted-host pypi.douban.com 模組名 //豆瓣
pip install -i http://pypi.mirrors.ustc.edu.cn/simple --trusted-host pypi.mirrors.ustc.edu.cn 模組名     //中科大
pip install -i https://mirrors.163.com/pypi/simple --trusted-host mirrors.163.com/pypi 模組名           //網易雲