简体   繁体   English

无法在 CentOS 7 上获得 Python 3.7 以使用已安装的 OpenSSL 1.1.1

[英]Can't get Python 3.7 on CentOS 7 to use installed OpenSSL 1.1.1

I've run searches all day without any luck or results.我整天都在运行搜索,但没有任何运气或结果。 I have built a Centos 7 server and installed Python 3.7 along with OpenSSL 1.1.1.我已经构建了一个 Centos 7 服务器并安装了 Python 3.7 和 OpenSSL 1.1.1。

However, when I run Python and perform the following:但是,当我运行 Python 并执行以下操作时:

import ssl
ssl.OPENSSL_VERSION

The output I get is OpenSSL 1.0.2k.我得到的 output 是 OpenSSL 1.0.2k。 When running openssl version at the prompt, I get OpenSSL 1.1.1.在提示符下运行 openssl 版本时,我得到 OpenSSL 1.1.1。

Both OpenSSL and Python were compiled on the machine. OpenSSL和Python都是在机器上编译的。

The correct OpenSSL is in the path.正确的 OpenSSL 在路径中。 Also tried to compile Python with the configure --with-openssl=/usr/local (location of the correct openssl).还尝试使用 configure --with-openssl=/usr/local (正确 openssl 的位置)编译 Python。

Thanks.谢谢。

[Edit] [编辑]
When I type当我输入

openssl version  
sudo openssl version  

I get different versions coming up.我得到了不同的版本。 The sudo openssl version is the same that I get through Python. sudo openssl 版本与我通过 Python 获得的版本相同。 $PATH with and without sudo is the same带和不带 sudo 的 $PATH 是一样的

When you compile Python, you need to tell it which OpenSSL headers and libraries to use.编译 Python 时,需要告诉它要使用哪些 OpenSSL 头文件和库。 Try this before running " ./configure " when building Python在构建 Python 时运行“ ./configure ”之前尝试此操作

export CFLAGS="$CFLAGS $(pkg-config --cflags openssl11)"
export LDFLAGS="$LDFLAGS $(pkg-config --libs openssl11)"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM