Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_P
因openssl 1.0.1存在安全问题,python3自3.7版本后要求依赖openssl 1.0.2以上或libressl;错误提示如下:
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_P
python3.7以上建议使用libressl代替openssl,故需通过源码编译安装libressl
# 下载源码包
wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.0.2.tar.gz
# 解压
tar -zxvf libressl-3.0.2.tar.gz
# 配置安装路径
mkdir /usr/local/libressl
cd libressl-3.0.2
./configure --prefix=/usr/local/libressl
# 安装
make -j8 & sudo make install
# 创建软连接代替openssl
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
ln -s /usr/local/libressl/bin/openssl /usr/bin/openssl
ln -s /usr/local/libressl/include/openssl /usr/include/openssl
echo /usr/local/libressl/lib >> /etc/ld.so.conf.d/libressl-3.0.2.conf
ldconfig -v
验证是否安装完成
openssl version
export LDFLAGS="-L/usr/local/libressl/lib"
export CPPFLAGS="-I/usr/local/libressl/include"
export PKG_CONFIG_PATH="/usr/local/libressl/lib/pkgconfig"
配置编译安装python
./configure --prefix=/usr/local/python37
make
make install
验证ssl 安装正确
import ssl没有报错
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类