2

I want my python GUI apps to run on all three OSs without need to recompile on each platform. Is python executable created by pyinstaller (by or similar utility) platform independent like Java's bytecode? Java's bytecode runs on Windows, Mac and Linux using JRE.

3
  • Python bytecode runs on a virtual machine, yes. But that's not really relevant to whether or not pyinstaller makes a protable executable Commented Jun 23, 2021 at 11:10
  • You don't need to tag this with [java]. You are not actually asking anything about Java, and your Q&A won't help someone asking about Java topics. Commented Jun 23, 2021 at 11:26
  • 1
    Note that if you bundle a Java application+JVM into an .exe file (or other platforms' equivalents), that will also be platform-specific. You can either have a cross-platform package that requires a VM/interpreter to be installed on the user's system; or you can have a self-contained executable without dependencies that works on a specific platform. You can't have a cross-platform executable with no dependencies (well, there's this, but that's still x64-specific and probably not viable for Python or Java). Commented Jun 23, 2021 at 11:33

1 Answer 1

6

It's right there in the documentation

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.

In other words: no, it's not portable. You need to compile for each platform/architecture.

As stated by @juanpa.arrivillaga in the comments, this has nothing to do with the bytecode python normally executes. That is portable. The problem here is that PyInstaller bundles a python interpreter that is os- and architecture- specific (that is, this doesn't work for the same reason you wouldn't normally be able to run a Windows executable on MacOs).

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

1 Comment

Important to note, this has nothing to do with Python bytecode which is portable to any machine that has the right version of the interpreter

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.