Reputation:
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?
Upvotes: 4
Views: 5954
Reputation: 17188
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.
Upvotes: 7
Reputation: 379
Linux checks magic number of executable file, magic number of a Linux executable file starts with "DLE elf"
execute "od -c YUPUR_FILE" and see result
Upvotes: 0