Anaconda 更換國內pip源


一、添加鏡像源

打開Linux終端或者Windows的命令行窗口,直接輸入以下命令:

1、添加清華源鏡像

conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

2、添加中科大鏡像源

conda config --add channels http://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels http://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels http://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels http://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels http://mirrors.ustc.edu.cn/anaconda/cloud/menpo/

這里注意一下:

  • 中科大好像停止鏡像源服務了,首選還是先用清華鏡像源吧。
  • 如果是Windows系統,可以在鏡像源的鏈接后面分別改成http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/
  • 有的博客可能會把鏡像源的協議寫成https,可能導致后面執行pip命令時報錯HTTP 000 CONNECTION FAILED for url,所以最好寫成http協議。

3、設置搜索時顯示channel地址

# 設置搜索時顯示通道地址
conda config --set show_channel_urls yes

4、配置文件地址

以上的配置信息全部會寫在一個名為.condarc的配置文件當中。

如果是LInux平台,配置文件的路徑為/home/username/.condarc

如果是Windows平台,配置文件路徑為C:\users\username\.condarc

因此除了通過以上的命令進行鏡像源修改之外,直接修改配置文件可以達到一樣的效果。
例如終端輸入以下命令,打開文件:

vim ~/.condarc

在文件中添加如下命令:

channels:
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
  - https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - defaults
show_channel_urls: true

二、刪除鏡像源

如果添加的鏡像源有問題,可以通過以下命令刪除全部鏡像源

conda config --remove-key channels


免責聲明!

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



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