Binaries I created with pyinstaller are incompatible with linux

binary, linux, pyinstaller, python

Solution

`pyinstaller` creates an executable that will work on the machine it is run on. So if you run pyinstaller on Windows, it creates an executable for Windows. Same for Mac, Linux, etc, so I'd try running pyinstaller on your Linux box to produce a working executable for that environment. Mac executables are not Linux executables.

This is because (as I understand it) the underlying Python includes platform-specific implementations of certain things. For instance, the `os` module has a bunch of conditional, platform-dependent imports that will be bundled into the executable. Since it only has access to whatever binaries are available on the platform `pyinstaller` is running on, it can't produce a version for other platforms.

Problem

I used the recent version pyinstaller with the option `--onefile` to create one stand alone file of my python script. On my Mac it works just fine if I open the file in the terminal (bash shell), but in the Linux bash I get the following error ``` bash: ./myprog: cannot execute binary file ``` Is there something I am missing here?

Original source