首次使用Anaconda的常規步驟——解決CondaHTTPError而導致的下載或更新中斷問題

當我們第一次使用Anaconda時,想要創建一個新環境,但是當使用命令conda  create --name 環境名 python=3.7(Python版本自選)時經常會出現類似CondaHTTPError: HTTP 000 CONNECTION FAILED for url 的錯誤,這是由於默認鏡像源的下載速度過慢而導致的下載或更新中斷,解決辦法就是更換鏡像源。推薦使用清華鏡像源,並刪除原鏡像源。

清華的開源軟件鏡像站:

https://mirror.tuna.tsinghua.edu.cn/help/anaconda/

操作步驟:

1. 在Anaconda Prompt窗口輸入以下命令:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

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

conda config --set show_channel_urls yes

2. 更改鏡像源配置文件

Windows用戶使用win+r鍵打開“運行”,並輸入%HOMEPATH%,找到.condarc文件,並更改內容爲:

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
ssl_verify: true
show_channel_urls: true

特別提醒:1和2的順序不能反!

配置好之後,重新輸入命令conda  create --name 環境名 python=3.7(Python版本根據需要自己選擇)就可以成功下載並安裝新環境啦~

例如:

conda create --name yuan python=3.7 

創建完成結果:當你使用activate 你創建的環境名就可以進入創建好的環境,並出現紅框所示(創建好的環境名)時就代表創建成功!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章