跳到主要内容

范例:pip安装python库报ssl错误-2023.6.17(已解决)

范例:pip安装python库报ssl错误-2023.6.17(已解决)

image-20230617080705956

目录

[toc]

1、报错现象

image-20230617070713032

C:\Users\Win>pip install ipython
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1124)'))': /simple/ipython/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1124)'))': /simple/ipython/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1124)'))': /simple/ipython/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1124)'))': /simple/ipython/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1124)'))': /simple/ipython/
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/ipython/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Max retries exceeded with url: /simple/ipython/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1124)'))) - skipping
ERROR: Could not find a version that satisfies the requirement ipython (from versions: none)
ERROR: No matching distribution found for ipython

2、报错环境

image-20230617070746592

win10

之前是有配置pip源为清华源:

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

3、测试过程

换其他源还是报错(失败)

image-20230617071102004

百度:替换为豆瓣源并加--trusted-host参数(成功)

原因分析:

无法访问到https://pypi.tuna.tsinghua.edu.cn/simple/pip,SSL证书认证问题。

解决办法:

pip install ipython --trusted-host pypi.tuna.tsinghua.edu.cn 在语句后面将其设置为可信任即可,问题得到了解决。

  • 使用清华源安装:(==会报错==)
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ipython --trusted-host pypi.tuna.tsinghua.edu.cn

image-20230617075925022

  • 使用豆瓣源安装:(==成功==)
pip install -i  http://pypi.douban.com/simple/ ipython --trusted-host pypi.douban.com

image-20230617080002978

可以看到,此时2023年6月17日清华源不能用了,这里就暂且使用豆瓣源即可。

  • 永久配置使用豆瓣源:
pip config set global.index-url http://pypi.douban.com/simple/

#后面使用如下命令安装python库就好
pip install ipython --trusted-host pypi.douban.com

image-20230617080318129

  • 推荐配置
pip config set global.index-url http://pypi.douban.com/simple/
pip config set install.trusted-host pypi.douban.com

#后面使用如下命令安装python库就好
#pip install ipython --trusted-host pypi.douban.com
pip install ipython

image-20230617110032972

参考文章

https://blog.csdn.net/qq_32473523/article/details/122087467

https://blog.csdn.net/yuan2019035055/article/details/127530222

关于我

我的博客主旨:

  • 排版美观,语言精炼;
  • 文档即手册,步骤明细,拒绝埋坑,提供源码;
  • 本人实战文档都是亲测成功的,各位小伙伴在实际操作过程中如有什么疑问,可随时联系本人帮您解决问题,让我们一起进步!

🍀 微信二维码 x2675263825 (舍得), qq:2675263825。

image-20230107215114763

🍀 微信公众号 《云原生架构师实战》

image-20230107215126971

🍀 语雀

https://www.yuque.com/xyy-onlyone

image-20230515221819681

🍀 csdn https://blog.csdn.net/weixin_39246554?spm=1010.2135.3001.5421

image-20230107215149885

🍀 知乎 https://www.zhihu.com/people/foryouone

image-20230107215203185

最后

好了,关于本次就到这里了,感谢大家阅读,最后祝大家生活快乐,每天都过的有意义哦,我们下期见!