利用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文件中应该是以下内容:
再次执行,安装成功!