构建 Python 3.7.1

编程入门 行业动态 更新时间:2024-10-27 08:31:33
本文介绍了构建 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, github/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 www.openssl/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 www.python/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

本文发布于:2023-10-24 07:43:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1523343.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!