Linux安装python3.8时,编译过程中报错Could not build the ssl module!

一、 Python编译安装缺失模块_ctypes

build correctly but finished with this message:

    Failed to build these modules:
    _ctypes

安装依赖库

sudo apt install build-essential  python3-dev libffi-dev

二、在安装Python3.8编译时报错:Could not build the ssl module!

Could not build the ssl module!
Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().
LibreSSL 2.6.4 and earlier do not provide the necessary APIs, 
https://github.com/libressl-portable/portable/issues/381

1.官网下载最新的openssl安装https://www.openssl.org/source/gitrepo.html

(1)查看openssl版本

openssl version

(2)解压安装包: 

sudo tar -zxf openssl-1.1.1h.tar.gz


(3)进入安装包依次执行:

./config 
make
make test
make install

 

然后重新安装Python3.8

BUT,依然失败! 不能加载ssl module

2.安装libressl

根据错误提示,发现需要安装libressl,所以需要重现下载和安装libressl 来替代openssl

(1)下载地址:https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.7.4.tar.gz

tar zxvf  libressl-2.7.4.tar.gz -C ./

cd cd libressl-2.7.4

./config --prefix=/usr/local

sudo make install

(2)新建或修改 /etc/ld.so.conf.d/local.conf 配置文件,添加如下内容:

/usr/local/lib

然后将 /usr/local/lib 目录加入到模块加载目录。
重新加载共享模块:

sudo ldconfig -v

重新编译Python3.8
回到 Python3.8目录,编辑安装文件 Modules/Setup
删除有关 ssl 编译代码的注释,共 4 行

SSL=/usr/local
_ssl _ssl.c \
        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
        -L$(SSL)/lib -lssl -lcrypto

这样重新编译python之后,就可以正常导入ssl模块了

(3)验证Python、pip、ssl

Linux安装python3.8时,编译过程中报错Could not build the ssl module!_第1张图片

OK~  大功告成!

三、安装缺少的zlib库

zipimport.ZipImportError: can't decompress data; zlib not available
Makefile:1099: recipe for target 'install' failed
make: *** [install] Error 1

安装指令:
 

sudo apt install zlibc zlib1g-dev

OK~

 

 

你可能感兴趣的:(Python,Python,ssl)