Python executable running on different Linux versions

Question:

I need to write a program that will be running in the end on CentOS (Version 6.3 – its a security appliance but I have root access)
I installed a development environment in Ubuntu and used pyinstaller to create a single executable. In PyCharm I can select between Python versions 2.7 and 3.6 – I tried both and created the exe.
The program works fine on Ubuntu, but unfortunately not under CentOS
CentOS shows me Python Version 2.66

Questions:

  • should it work in general?

  • I am getting errors- (missing lib’s) (but files exist):
    "./ICC: /lib64/libc.so.6: version `GLIBC_2.14′ not found (required by /tmp/_MEIoHOzeE/libz.so.1)" – I assume the versions do not match?

  • is it important which python version is installed on CentOS (2.66) (I was hoping the executable would contain everything needed?)

  • I used pyinstaller with the option "–onefile"

  • I added "#!/usr/bin/python" as first line of my source code

  • if I run the.py file (source code) I get multiple errors:

    ./ICC.py: line 1: import: command not found
    ./ICC.py: line 2: import: command not found
    ./ICC.py: line 13: version: command not found
    ./ICC.py: line 24: try:: command not found
    ./ICC.py: line 25: syntax error near unexpected token (' ./ICC.py: line 25: logfile = open ("/tmp/icm-log.txt","w")’

(same code runs fine on ubuntu, guess things have changed in newer python versions which would make sense)

  • Do I need to write the program in Python 2.66? Do I need to move development to CentOS?

  • I cannot upgrade Python on CentOS as it might break other things

Any recommendations, ideas, hints on how to make this work.

Asked By: MilesAhead66

||

Answers:

When you use PyInstaller to create an executable binary you must do so on the target machine or target environment.

The output of PyInstaller is specific to the active operating system and the active version of Python. This means that to prepare a distribution for:

  • a different OS
  • a different version of Python
  • a 32-bit or 64-bit OS

you run PyInstaller on that OS, under that version of Python. The Python interpreter that executes PyInstaller is part of the bundle, and it is specific to the OS and the word size."

More info available here

Answered By: Kevin S
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.