Anaconda 安裝第三方模塊失敗解決辦法--修改鏡像-CondaHTTPError: HTTP 000 CONNECTION FAILED for url

利用conda命令來安裝第三方庫時出現了以下問題:
 

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://conda.anaconda.org/'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'/win-64/repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
ConnectionError(MaxRetryError("HTTPSConnectionPool(host='conda.anaconda.org', port=443): Max retries exceeded with url: /'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'/win-64/repodata.json (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x0000029249BF63C8>: Failed to establish a new connection: [Errno 11002] getaddrinfo failed',))",),)


網上查說是因爲Anaconda默認的鏡像源大部分都在國外,國內很多網絡環境下,訪問不穩定,下載速率慢造成的,需要修改鏡像源爲國內鏡像,目前國內的主要鏡像源爲

清華大學的鏡像:https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

中科大:https://mirrors.ustc.edu.cn/anaconda/pkgs/free/

添加鏡像源:

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

執行,發現仍然不成功:

添加中科大鏡像源:

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

同時刪除默認的鏡像源:

conda config --remove channels defaults

打開C:\Users\用戶名\.condarc(注:根據自己的文件修改路徑)這個文件刪除 -defaults這一行,.condarc文件中應該是以下內容:

再次執行,安裝成功!

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