pip Can‘t connect to HTTPS URL because the SSL module is not available.

问题描述

环境:

  • Python 3.10.5
  • pip 22.1.2

在尝试pip install request-html时候爆出如下错误:

Could not fetch URL https://pypi.org/simple/pyecharts/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pyecharts/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement pyecharts (from versions: none)
ERROR: No matching distribution found for pyecharts

解决办法

看报错信息究其本质应该是在运行的时候缺少ssl模块

所以先尝试了关闭SSL认证并添加trusted host(如下是pip.conf的配置,关于pip.conf如何配置请参考)

[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple/
extra-index-url=
        http://mirrors.aliyun.com/pypi/simple/
        http://pypi.douban.com/simple
        http://pypi.mirrors.ustc.edu.cn/simple/

[install]
trusted-host=
        pypi.tuna.tsinghua.edu.cn
        mirrors.aliyun.com
        pypi.douban.com
        pypi.mirrors.ustc.edu.cn
        download.openmmlab.com

proxy_servers:
  http: http://xxx.xxx.x.xx:8080
  https: https://xxx.xxx.x.xx:8080
ssl_verify: false

或者使用自定义(非默认路径)pip.conf

export PIP_CONFIG_FILE=/path/to/pip.conf

但是这个办法毕竟只是绕过去,但是依旧使得很多需要ssl模块的库不能运行,毕竟缺少这个库,就比如我要安装的requests-html。

要解决这个问题就需要重新编译(安装)python,并重新配置好对应的openssl版本 [1][2][3]。

[1]https://stackoverflow.com/questions/5937337/building-python-with-ssl-support-in-non-standard-location
[2]https://peps.python.org/pep-0644/
[3]https://techglimpse.com/install-python-openssl-support-tutorial/

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值