2

I have compiled the python3.6 program on CentOS 6.8 using pyinstaller and tested on a newer version of Linux. It's working as expected. CentOS 6.8 has installed GLIBC 2.12

pyinstaller --onefile --clean --hidden-import sqlite3 --hidden-import pycryptodome my_python.py

However, I'm getting the follwing error when execute the compiled program on Redhat 5.8 as it has installed the GLIBC 2.5

[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)

Can you please help me how to compile the python3.6 program on CentOS 6 for Redhat 5.8?

P.S: I cannot update the GLIBC as I'm going to distribute the same program to the many Linux servers.

  • You compiled on one system, and then ran it on another system? That won't fly if the dependencies are not the same, such as glibc here. – 9769953 Aug 09 '18 at 12:40

1 Answers1

2

Answer to this question is listed in pyinstaller's FAQ as first one in GNU/Linux section. Here it is, a bit cut down version with my emphasis.

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.

Shorrer
  • 104
  • 2
  • 3
  • I'm trying to install python3.6 on Redhat5.8 but unfortunately, there is no support for the repository. Is there any way to install python3.6 on Redhat 5.8? – Rama Chandran Aug 09 '18 at 13:37
  • Compiling it from source is always an option. Here (https://stackoverflow.com/questions/8087184/installing-python-3-on-rhel) you can see the process in details. Hope that will help you – Shorrer Aug 09 '18 at 14:42