python3.9.6 版本没有 ssl 如何解决
CentOS/RHEL 系统
1. 安装 SSL 相关依赖
sudo yum install -y openssl-devel
2. 下载并解压 Python 3.9.6 源码
wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tgz
tar -xzvf Python-3.9.6.tgz
cd Python-3.9.6
3. 配置编译选项
同样指定 --with-ssl
选项:
./configure --with-ssl
4. 编译并安装 Python
make -j$(nproc)
sudo make install
验证 SSL 支持
安装完成后,可以通过以下 Python 代码验证 SSL 支持是否正常:
import ssl print(ssl.OPENSSL_VERSION)
将上述代码保存为一个 .py
文件(例如 test_ssl.py
),然后在终端中运行:
python3 test_ssl.py
如果能正常输出 OpenSSL 的版本信息,说明 SSL 支持已成功安装到 Python 3.9.6 中。