当前位置:首页 » 《我的小黑屋》 » 正文

pip is configured with locations that require TLS/SSL, however the ssl module in Python is notable

25 人参与  2024年09月17日 12:41  分类 : 《我的小黑屋》  评论

点击全文阅读


现象

执行pip install时报错:

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.Hint: It looks like a path. The path does exist. WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

原因

没有通过该SSL安全协议的认证,通常是由于开启了网络代理、VPN 或者网络抓包等软件的导致的

解决办法

临时关闭代理、VPN 或者网络抓包等软件
最推荐的办法是临时关闭代理、VPN 或者网络抓包等软件,但是如果关闭后下载速度过慢可以尝试后面两种解决办法

通过镜像的 HTTP 源来避免 SSL 认证问题【推荐】
由于是 SSL 是 HTTPS 协议需要的,因此我们可以切换至 HTTP 的镜像站来进行安装下载

HTTPS 现在已经比较普及,有不少镜像源也早已经切换至 HTTPS 协议,但部分镜像源在支持 HTTPS 协议的而同时也还支持 HTTP 协议,下面简单罗列几个 pip 镜像源

# 清华,仅支持 HTTPShttps://pypi.tuna.tsinghua.edu.cn/simple/# 阿里,HTTP 和 HTTPS 均支持http://mirrors.aliyun.com/pypi/simple/https://mirrors.aliyun.com/pypi/simple/# 豆瓣,HTTP 和 HTTPS 均支持http://pypi.doubanio.com/simple/https://pypi.doubanio.com/simple/

安装时第三方包时可以参考如下命令:

pip install xxx-package -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.compip install -r requirements.txt -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com

如果想永久使用镜像站,则需要修改配置文件,以 Linux 为例:

vim ~/.pip/pip.conf

修改文件内容如下

[global]index-url = http://mirrors.aliyun.com/pypi/simple/[install]trusted-host = mirrors.aliyun.com
切换至低版本 pip
据说 pip 版本高于 20.3 后才会出现此错误,因此我们可以手动将 pip 版本降级至 20.2.4 或者 20.3b1 等较低版本即可
python -m pip install pip==20.2.4 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.compython -m pip install pip==20.2.4 -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
检查环境,如windows配置环境变量
D:\Anaconda3 D:\Anaconda3\ScriptsD:\Anaconda3\Library\bin 
【阿里云】PyPI 镜像

点击全文阅读


本文链接:http://zhangshiyu.com/post/160911.html

<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1