构建 Python 3.7.1 - SSL 模块失败

新手上路,请多包涵

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

 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。

 ./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

有任何想法吗?

原文由 mcatis 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 3k
1 个回答

仅仅因为 这个博客,我在 3 天后解决了它。 使用 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。

安装 ssl 1.0.2 或更高版本。

     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 配置脚本中。

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

现在继续安装 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 并输入:

 import ssl
ssl.OPENSSL_VERSION

希望能帮助到你!

原文由 Sunil Kumar 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题