我已经使用pyinstaller在CentOS 6.8上编译了python3.6程序,并在较新版本的Linux上进行了测试。它按预期工作。 CentOS 6.8已安装GLIBC 2.12
pyinstaller --onefile --clean --hidden-import sqlite3 --hidden-import pycryptodome my_python.py
但是,由于安装了 GLIBC 2.5,所以在 Redhat 5.8 上执行编译的程序时出现以下错误
[24522] Error loading Python lib '/tmp/_MEIl16Rvq/libpython3.6m.so.1.0': dlopen: /lib64/libc.so.6: version `GLIBC_2.7' not found (required by /tmp/_MEIl16Rvq/libpython3.6m.so.1.0)
您能帮我在 CentOS 6 for Redhat 5.8 上编译 python3.6 程序吗?
P.S:我无法更新 GLIBC,因为我要将相同的程序分发到许多 Linux 服务器。
最佳答案
此问题的答案列在 pyinstaller's FAQ 中作为 GNU/Linux 部分的第一个。这是我强调的一个精简版。
The executable that PyInstaller builds is not fully static, in that it still depends on the system libc. Under Linux, the ABI of GLIBC is [...] not forward compatible. [...] The supplied binary bootloader should work with older GLIBC. However, the libpython.so and other dynamic libraries still depends on the newer GLIBC. The solution is to compile the Python interpreter with its modules (and also probably bootloader) on the oldest system you have around, so that it gets linked with the oldest version of GLIBC.
关于linux - 如何为Redhat 5.8/CentOS 5编译python3.6程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51767076/