构建 Python 3.7.1 - SSL 模块失败 [英] Building Python 3.7.1 - SSL module failed

查看:27
本文介绍了构建 Python 3.7.1 - SSL 模块失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从源代码构建 Python 3.7 遇到以下错误:

Building Python 3.7 from source runs into following error:

Failed to build these modules:
_hashlib              _ssl                                     

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

我从其他 stackoverflow 问题中尝试了很多解决方法,但它不起作用.我从源代码构建了最新的 OpenSSL 和 LibreSSL.OpenSSL 路径为:/usr/local/ssl",版本为 OpenSSL 1.0.2p.

I tried so many workarounds from other stackoverflow-questions, but it doesnt work. I build newest OpenSSL and LibreSSL from source. OpenSSL path is: "/usr/local/ssl" with version OpenSSL 1.0.2p.

./configure --with-openssl=/usr/local/ssl/
(./configure CPPFLAGS="-I/usr/local/ssl/include" LDFLAGS="-L/usr/local/ssl/lib")
make 
make altinstall

我的系统:Ubuntu 12.04.5 LTS

My system: Ubuntu 12.04.5 LTS

有什么想法吗?

推荐答案

我在 3 天后解决它只是因为 此博客. 使用 python 3.7.4 openssl 1.1.0 centOS 6.

I solved it after 3 days only because of this blog. with python 3.7.4 openssl 1.1.0 centOS 6.

总结如下:

首先,一些先决条件:

sudo apt-get install build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

如果使用 centos linux,请使用 yum 而不是 apt-get.

use yum instead of apt-get if using centos linux.

安装 ssl 1.0.2 或更高版本.

Install ssl 1.0.2 or higher.

    cd /usr/src
    curl https://www.openssl.org/source/openssl-1.0.2o.tar.gz | tar xz
    cd openssl-1.0.2o
    ./config shared --prefix=/usr/local/
    sudo make
    sudo make install

我们需要将/usr/src/openssl-1.0.2o 传递到 Python 配置脚本中.

We will need to pass /usr/src/openssl-1.0.2o into the Python configure script.

mkdir lib
cp ./*.{so,so.1.0.0,a,pc} ./lib

现在继续安装 Python:

Now proceed with installing Python:

    cd /usr/src
    sudo wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
    sudo tar xzf Python-3.7.0.tgz
    cd Python-3.7.0
    ./configure --with-openssl=/usr/src/openssl-1.0.2o --enable-optimizations
    sudo make
    sudo make altinstall

要测试一下,运行 python3.7 并输入:

To test it out, run python3.7 and input:

import ssl
ssl.OPENSSL_VERSION

希望能帮到你!

这篇关于构建 Python 3.7.1 - SSL 模块失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆