我需要在RHEL上安装几个Python模块,我没有root访问权限.至少有一个模块也需要访问Python.h.
在这种情况下,我发现最好的方法是安装python及其依赖项~/local.它通常只是工作,但这次Python无法构建SSL模块(请参阅下面的详细信息).这是我正在做的事情的痕迹.
所以我下载了python 6源码然后关闭了我:
./configure --prefix=/home/fds/rms/local
make >& make.log
Run Code Online (Sandbox Code Playgroud)
对日志的检查显示ssl模块尚未编译,但没有提及原因(make或configure中没有其他ssl出现):
Failed to find the necessary bits to build these modules:
_bsddb _curses _curses_panel
_hashlib _sqlite3 _ssl <----------
Run Code Online (Sandbox Code Playgroud)
所以我想,python根本找不到任何ssl库(这很奇怪,但是嘿......).所以我下载openssl-0.9.8r和
./config --prefix=/home/fds/rms/local shared
make
make install
Run Code Online (Sandbox Code Playgroud)
现在回到Python,我./configure并重新制作.它失败了,但这一次有所不同:
Failed to build these modules:
_hashlib _ssl
Run Code Online (Sandbox Code Playgroud)
仔细检查日志文件可以发现:
gcc -pthread -shared build/temp.linux-x86_64-2.6/home/fds/rms/installers/Python-2.6.6/Modules/_ssl.o -L/home/fds/rms/local/lib -L/usr/local/lib -lssl -lcrypto -o build/lib.linux-x86_64-2.6/_ssl.so
*** WARNING: renaming "_ssl" since importing it failed: libssl.so.0.9.8: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)
所以现在它正在拿起图书馆,但不是很正确(文件应该在哪里):
$ find /home/fds/rms/local …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 RHEL 上编译 python,因为我当前的 python 使用的是旧的 1.0.2k ssl 版本。
\n(test_env) [brad@reason tlscheck]$ python3 --version\nPython 3.9.3\n(test_env) [brad@reason tlscheck]$ python3 -c "import ssl; print(ssl.OPENSSL_VERSION)"\nOpenSSL 1.0.2k-fips 26 Jan 2017\n(test_env) [brad@reason tlscheck]$ openssl version\nOpenSSL 1.1.1l 24 Aug 2021\nRun Code Online (Sandbox Code Playgroud)\n我认为问题是当我编译 3.9.3 时,我没有更新我的 OpenSSL 版本。我已经更新了我的 OpenSSL 并需要将它与 python 一起使用。所以我下载了最新的python 3.10,但在make阶段我收到一个错误,它不会用ssl制作。我的消息如下:
\nFollowing modules built successfully but were removed because they could not be imported:\n_hashlib _ssl \n\n\nCould not build the ssl module!\nPython requires a OpenSSL 1.1.1 or newer\nRun Code Online (Sandbox Code Playgroud)\n这是尝试编译的完整日志:\n https://pastebin.com/36EntpFz
\n当我使用 @tony-yip 提到的配置选项时,我在配置中得到以下内容。 …
我正在尝试根据https://bugs.python.org/issue29095上的说明在macOS 10.11上编译Python 3.6.2 .
我用自制OpenSSL的安装到标准位置,然后加入LDFLAGS,CFLAGS以及CPPFLAGS我ENV:
$ printenv | grep FLAGS
LDFLAGS=/usr/local/Cellar/openssl/1.0.2l/lib/
CFLAGS=-I/usr/local/Cellar/openssl/1.0.2l/include/openssl
CPPFLAGS=-I/usr/local/Cellar/openssl/1.0.2l/include/openssl
Run Code Online (Sandbox Code Playgroud)
然后在同一个shell中,我将Python编译到我的用例所需的自定义位置:
$ sudo ./configure --prefix=/oebuild/python/python-3.6.1
$ sudo make
$ sudo make install
Run Code Online (Sandbox Code Playgroud)
但是,SSL模块无法构建.构建日志说明了这一点:
Python构建成功完成!找不到构建这些可选模块的必要位:_gdbm _ssl ossaudiodev
spwd
要查找必要的位,请在detect_modules()中的setup.py中查找模块的名称.