python pip install报错 unable to get local issuer certificate (_ssl.c:1125) code example解决方法

本质是ssl证书认证失败。我们需要访问的是http的链接,但是访问https:的了,所以访问失败。

报错信息

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(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:1125)’))) - skipping

解决方案

直接设置global的配置,即到C:/ProgramData下创建pip文件夹,新建pip.ini
查看pip global路径

pip -v config list
image.png

新建文件夹以及pip.ini文件

image.png

放入信任地址

[global]
trusted-host = pypi.python.org
               pypi.org
               files.pythonhosted.org
               pypi.douban.com
               mirrors.tuna.tsinghua.edu.cn
               mirrors.aliyun.com
image.png

禁用ssl_verify

pip config set global.ssl_verify false

使用清华源

pip install openpyxl -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn

参考:官网 https://pip.pypa.io/en/latest/topics/configuration/

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容