我需要在RHEL上安装几个Python模块,我没有root访问权限 . 至少有一个模块还需要访问 Python.h
.
在这种情况下,我发现最好的方法是在 ~/local
中安装python及其依赖项 . 它通常只是工作,但这次Python无法构建SSL模块(请参阅下面的详细信息) . 这里's the trace of what I'在做什么 .
所以我下载了python 6源码然后关闭了我:
./configure --prefix=/home/fds/rms/local
make >& make.log
对日志的检查显示ssl模块尚未编译,但没有提及原因(make或configure中没有其他ssl出现):
Failed to find the necessary bits to build these modules:
_bsddb _curses _curses_panel
_hashlib _sqlite3 _ssl <----------
所以我想,python根本找不到任何ssl库(这很奇怪,但是嘿......) . 所以我下载openssl-0.9.8r和
./config --prefix=/home/fds/rms/local shared
make
make install
现在回到Python,我./configure并重新制作 . 它失败了,但这一次有所不同:
Failed to build these modules:
_hashlib _ssl
仔细检查日志文件可以看出:
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
所以现在它正在拿起图书馆,但并没有完全正确(文件应该在哪里):
$ find /home/fds/rms/local -iname libssl.so.0.9.8
/home/fds/rms/local/lib/libssl.so.0.9.8
接下来就是跟踪make并查看它在哪里寻找文件:
$ strace -f make 2>&1 | grep libssl.so.0.9.8
[pid 5584] open("/lib/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/lib64/tls/x86_64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/lib64/tls/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/lib64/x86_64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/lib64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib64/tls/x86_64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib64/tls/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib64/x86_64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] write(1, "*** WARNING: renaming \"_ssl\" sin"..., 131*** WARNING: renaming "_ssl" since importing it failed: libssl.so.0.9.8: cannot open shared object file: No such file or directory
[pid 5584] open("/lib/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/lib64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib64/tls/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] open("/usr/lib64/libssl.so.0.9.8", O_RDONLY) = -1 ENOENT (No such file or directory)
[pid 5584] write(1, "*** WARNING: renaming \"_hashlib\""..., 135*** WARNING: renaming "_hashlib" since importing it failed: libssl.so.0.9.8: cannot open shared object file: No such file or directory
嗯,它正在寻找所有错误的地方 . 我试着给出一个提示:
CPPFLAGS="-I/home/fds/rms/local/include -I/home/fds/rms/local/include/openssl" LDFLAGS="-L/home/fds/rms/local/lib" ./configure --prefix=/home/fds/rms/local
但没有任何改变, make
似乎根本没有尝试 /home/fds/rms/local/lib
.
多年来我没有这样做,所以也许我忽略了一些东西 . 有人可以帮忙解决这个问题吗?
提前致谢 .
9 回答
对我来说编辑
Modules/Setup
是不够的,因为_hashlib
模块仍然使用错误的OpenSSL版本;在我的SLES系统上运行时没有考虑LD_LIBRARY_PATH
.通过根据GitHub patch: eddy-geek/ python_custom_openssl.diff编辑
setup.py
然后make clean && make
,将本地OpenSSL静态链接到_ssl
和_hashlib
的作用是什么 .有关我在Coredump when compiling python with a custom openssl version上使用Stack Overflow上的静态链接的原因的更多详细信息 .
对于 MAC OS HIGH Sierra 和 Python-3.5.6 使用brew安装openssl
这将在/usr/local/Cellar/openssl/1.0.2o_2/上安装openssl . 此路径需要在Modules / Setup.dist中更新
在上面的行中更新SSL值
并取消注释行,做一个CMM,你的python将用openssl编译 .
尝试将
-Wl,-rpath,/home/fds/rms/local/lib
添加到LDPATH
.我有一组静态openssl和静态libintl的补丁,下面是2和3 .
对于openssl(第一个补丁),您必须设置env var OPENSSL_ROOT .
这是基于http://gist.github.com/eddy-geek/9604982的补丁 .
对于Python 2.7.14:
https://gist.github.com/rkitover/2d9e5baff1f1cc4f2618dee53083bd35
https://gist.github.com/rkitover/afab7ed3ac7ce1860c43a258571c8ae1
对于Python 3.6.3:
https://gist.github.com/rkitover/93d89a679705875c59275fb0a8f22b45
https://gist.github.com/rkitover/b18f19eafda3775a9652cc9cdf3ec914
如果OpenSSL不在标准位置,则需要编辑
Modules/Setup.dist
以指定OpenSSL的位置 . 来自Getting SSL Support in Python 2.5.1:在Bourne shell中(/ bin / sh或/ bin / bash):
在C-shell中(/ bin / csh或/ bin / tcsh):
这是我在Python 2.7.11中使用的完整过程 .
在顶级Python2.7.11源目录中:
Modules/Setup.dist
,Modules/Setup
:取消注释_ssl
部分,注释掉_socket
(如果已经注释掉,则为no-op),取消注释并适当设置SSL(新ssl的路径lib/includes
等)注意:模块/设置文件最初不存在,但是在第一次运行后,我从相信的Modules / Setup.dist获取内容 . 确保每次运行前都会在此处反映更改 .
我正在构建Python2.7.13,我看到了同样的问题 . 对于2.7.13,您必须使用“openssl1.0.0e”或更高版本让它起作用 . 我试过openssl-0.9.8g并没有用 . 不知怎的,我不能让它只修改Modules / Setup.dist,所以我必须手动编译_ssl.o . 我想这是因为我提供的openssl-0.9.8g无法正常工作,它搜索了系统默认的libssl.so.10,它也不起作用 .
我得到了相同的结果,直到我回到openssl的日志 . 在那里我看到你需要在构建openssl时使用-fPIC:构建'_ssl'扩展:
然后,make,make为openssl安装,然后再次构建Python .