Python3.8中SSL模块不可用
我有一台运行RHEL6.10的机器,我按照下面的步骤安装了python3.8。
wget https://www.python.org/ftp/python/3.8.16/Python-3.8.16.tar.xz
tar xcf Python-3.8.16.tar.xz
cd Python-3.8.16.tar.xz
./configure
make altinstall
pip3.8 install shareplum
但是在使用pip命令安装任何模块时,我遇到了找不到ssl模块的错误。
[root@xyzPython-3.8.16]# pip3.8 install shareplum
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: 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/shareplum/
WARNING: 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/shareplum/
WARNING: 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/shareplum/
WARNING: 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/shareplum/
WARNING: 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/shareplum/
Could not fetch URL https://pypi.org/simple/shareplum/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/shareplum/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
虽然我检查过openssl是否安装了,它在机器上是可用的。希望大家能帮忙,指点一下缺少的部分。
[root@xyzPython-3.8.16]# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013
[root@xyzPython-3.8.16]# which openssl
/usr/bin/openssl
[root@xyzPython-3.8.16]# whereis openssl
openssl: /usr/bin/openssl /usr/lib64/openssl /usr/include/openssl /opt/splunkforwarder/bin/openssl /usr/share/man/man1/openssl.1ssl.gz
[root@xyzPython-3.8.16]#
1 个回答
0
Python 3需要1.1.1或更新版本的OPEN SSL - https://peps.python.org/pep-0644/
使用最新版本的openssl。我建议你使用以下命令:
./configure --enable-optimizations
在配置过程中,你会看到关于ssl的选项,确保它显示为yes。
这个选项会启用“性能指导优化”(PGO)和“链接时优化”(LTO)。
这两种优化方式会让构建过程变得比较慢,但能显著提高运行速度(我记得大约能提升10-20%)。
--enable-optimizations在编译Python时有什么作用?