打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
centos7 python3.7 ssl_Python3.7安装(解决ssl问题)

注:本博文主要为转载后根据本人情况再加工

1 问题:

python3.7.2安装遇到如下ssl问题

>>> import ssl

Traceback (most recent call last):

File "", line 1, in

File "/usr/local/lib/python3.7/ssl.py", line 98, in

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

ModuleNotFoundError: No module named '_ssl'

2 解决办法

2.1安装依赖

yum groupinstall development

2.2 安装libressl代替openssl-devel

2.2.1 原因

由于系统的openssl是1.0.1的版本,对于python3.7太老了,需要更新为openssl1.0.2或者libressl2.64(不含)以后的版本,所以这里从libressl官网下载libressl源码,编译生成库文件代替系统的openssl1.0.1

2.2.2 安装libressl

下载libressl-2.8.0

./config –prefix=/usr/local/libressl

make

make intall

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

2.2.3 加载lib

cd /etc/ld.so.conf.d

新建文件

vim libressl-2.8.0.conf

#将以下行加入文件,并保存

/usr/local/libressl/lib

ldconfig -v #重新加载库文件

2.3安装python3.7

从官网下载python3.7的源码,

解压后进入Python-3.7.0

编译前需要设置环境变量(重要)

export LDFLAGS="-L/usr/local/libressl/lib"

export CPPFLAGS="-I/usr/local/libressl/include"

export PKG_CONFIG_PATH="/usr/local/libressl/lib/pkgconfig"

./configure –prefix=/usr/local/python3 –enable-shared CFLAGS=-fPIC

运行后会出现一堆信息:

注意最后的ssl检查,如下图所示:

2.4 处理异常

运行python3.7命令遇到:libpython3.7m.so.1.0: cannot open shared object file: No such file or d

echo /usr/local/python3.7/lib > /etc/ld.so.conf.d/python3.7.conf

ldconfig -v

2.4 验证

linux下gunicorn+flask项目的部署

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
linux升级OpenSSL
Linux 从源码编译安装 OpenSSL
mosquitto 参数怎么配置
CentOS7安装Python3
解决RedHat没有openssl情况下编译程序(添加https处理)出现的问题
linuxblog | [转]openSSH服务的安装和配置
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服