1

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.

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the lightning fast answer :-) One more question: will I be able to run my Python 3 program on the machine running python 2? Do you know?
If everything else is equal, i.e. same OS, same libraries, etc. then Yes. In fact, you could even not have python installed at all on the destination computer because it won't use it. When PyInstaller creates an executable it packages the entire python interpreter with it. So if you compile on ubuntu using Python 3 and then deploy your executable to another ubuntu computer that has the same libraries but doesn't have python installed at all, or has a different version of python installed, it will work fine.
Thanks! So I made a copy of the VM and tried to install Python here, hoping I could create the exe file here and copy it to the other machine. I end up with this: Python-3.6.0]# ./configure checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking for python3.6... no checking for python3... no checking for python... python checking for --enable-universalsdk... no checking for --with-universal-archs... no checking MACHDEP... linux checking for --without-gcc... no checking for --with-icc... no checking for gcc... no ....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.