当前位置: 代码网 > it编程>前端脚本>Python > python3中No module named _ssl的问题解决

python3中No module named _ssl的问题解决

2024年08月22日 Python 我要评论
一、原因因openssl 1.0.1存在安全问题,python3自3.7版本后要求依赖openssl 1.0.2以上或libressl;错误提示如下:python requires an openss

一、原因

因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
cd libressl-3.0.2

# 配置安装路径
mkdir /usr/local/libressl
./configure --prefix=/usr/local/libressl

# 安装
make -j8
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没有报错

到此这篇关于python3中no module named _ssl的问题解决的文章就介绍到这了,更多相关python3 no module named _ssl内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网! 

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com