centos7 python3.7 ssl_Python 3.7无法连接到HTTPS URL,因为SSLmodule不可用

在CentOS 6.10上安装Python 3.7后,遇到SSL模块不可用的问题,导致无法通过pip3安装库如twisted。已尝试更新OpenSSL、libffi-devel并进行重新配置,但问题依然存在。启动Python3.7时导入ssl模块失败,报错ModuleNotFoundError: No module named '_ssl'。寻求解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我正在运行centos 6.10的专用服务器上安装Python 3.7

在跳了几圈试图做到这一点之后,我又犯了一个错误。使用Python3.7来尝试保持最新,pip安装中出现SSL问题是一个相当常见的问题。我得出的结论是,解决这个问题的最佳方法是获得正确版本的OpenSSL。所以我这样做了,编辑我的python modules/Setup.dist文件,重新配置它,重新运行make altinstall,尽管一切看起来都很好。出于某种原因,我以前运行这个python时使用的命令Python3.7突然变成了一个无法识别的命令,而Python3.7目录中有一个文件夹python,在执行时(在编辑环境路径后)该文件夹打开了Python3.7。以前不是这样,只是Python3.7有人知道这里可能发生了什么吗?

而且,我对整个SSL的事情几乎是束手无策了,我读到了《太阳底下》的每一篇文章。以下是我最近执行的一些命令的列表:#Unpacked Python3.7 into /usr/src directory

./configure --enable-optimizations --enable-loadable-sqlite-extensions

make altinstall

#installation failed from no '_ctypes' module

yum install libffi-devel

#repeat configure above

#yaaay python

#Successfully installed pip-10.0.1 setuptools-39.0.1 was the final message of the installation

Python3.7 -m venv /my/project/directory/ENV

pip install {library}

#this is where my issues began with SSL

日志:(ENV) [root@s1.1.1.1 ProjectDirectory]# pip3 install twisted

pip is configured with locations that require TLS/SSL, however, the SSL module in Python is not available.

Collecting twisted

Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/twisted/

Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/twisted/

Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/twisted/

Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/twisted/

Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/twisted/

Could not fetch URL https://pypi.org/simple/twisted/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/twisted/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

Could not find a version that satisfies the requirement twisted (from versions: )

No matching distribution found for twisted

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 SSLmodule is not available.")) - skipping

所以我觉得很酷。别担心。最新版本的Python甚至不能让pip3立即发布。精彩的。好吧,我开始像我们一样搜索谷歌,得出的结论是,每个人都只是重新配置他们的python,它神奇地工作了。不知道为什么,但可以。我很喜欢。我发现这篇文章:

想得很酷。如果我能得到python3.7ssl,那么它应该能让pip3正常工作?错了。不幸的是,如果我用上面提到的新的奇怪方式启动Python3.7,并键入import ssl,就会得到这个错误:Traceback (most recent call last):

File "", line 1, in

File "/usr/src/Python-3.7.0/Lib/ssl.py", line 98, in

import _ssl # if we can't import it, let the error propagate

ModuleNotFoundError: No module named '_ssl'

有人能帮我吗?我有点迷失在海洋里,我不知道怎么游泳。。。任何事情都会很棒,但我是一个服务器管理员的东西,所以越简单越好:)提前谢谢。

编辑:

顺便说一句yum install openssl

以及yum install openssl-devel

两者都会导致“已安装”标志。。。所以我不认为这是另一个解决办法。然而,当我手动安装时,我使用了版本1.1.1,因为我知道3.7出于任何原因放弃了对几个不同版本OpenSSL的支持。我认为已经安装了百胜的是1.0.2。我不知道centos 6.10平台是否有足够的容量,尽管版本有限制。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值