报错解决: CondaHTTPError: HTTP 000 CONNECTION FAILED for url ***
https协议比http协议多了SSL,TLS等验证和加密的阶段,可能是在与清华源进行SSL验证的过程中会出问题,因此需要关掉SSL验证,或者改用http协议。但是使用SSL验证是有助于保障传输过程的可靠性的。在我设置好国内源之后,用conda创建虚拟环境,下载python版本时出现以下错误。内容(即conda channels设置)如下。
Conda 清华源连接失败原因与解决
问题描述
在我设置好国内源之后,用conda创建虚拟环境,下载python版本时出现以下错误。
Solving environment: failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch/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.
SSLError(MaxRetryError(‘HTTPSConnectionPool(host=‘mirrors.tuna.tsinghua.edu.cn’, port=443): Max retries exceeded with url: /anaconda/pkgs/free/noarch/repodata.json (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘ssl3_get_server_certificate’, ‘certificate verify failed’)],)”,),))’,),)
我的~/.condarc
内容(即conda channels设置)如下
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64
show_channel_urls: true
解决方案
在我查阅了多篇博客,尝试了多种方案之后,终于找到两种解决方案:
- conda clean -i
- 先conda config 生成 .condarc
- 在命令行中输入
conda config --set ssl_verify false
修改设置,或者在文件~/.condarc
末尾添加一行ssl_verify: false
(有则修改即可) - 将https改成http
两种方法选一种即可
原因分析
https协议比http协议多了SSL,TLS等验证和加密的阶段,可能是在与清华源进行SSL验证的过程中会出问题,因此需要关掉SSL验证,或者改用http协议。但是使用SSL验证是有助于保障传输过程的可靠性的。
参考
[1] https://blog.csdn.net/qq_34573716/article/details/89958718

GitCode 天启AI是一款由 GitCode 团队打造的智能助手,基于先进的LLM(大语言模型)与多智能体 Agent 技术构建,致力于为用户提供高效、智能、多模态的创作与开发支持。它不仅支持自然语言对话,还具备处理文件、生成 PPT、撰写分析报告、开发 Web 应用等多项能力,真正做到“一句话,让 Al帮你完成复杂任务”。
更多推荐
所有评论(0)