Python 与 Java 字节码

标签 python pyinstaller bytecode platform-independent

我希望我的 python GUI 应用程序可以在所有三个操作系统上运行,而无需在每个平台上重新编译。 pyinstaller(通过或类似实用程序)创建的 python 可执行文件是否像 Java 的字节码一样独立于平台? Java 的字节码使用 JRE 在 Windows、Mac 和 Linux 上运行。

最佳答案

它就在 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.

换句话说:不,它不可移植。您需要针对每个平台/架构进行编译。

正如@juanpa.arrivillaga 在评论中所述,这与 python 通常执行的字节码无关。 便携的。这里的问题是 PyInstaller 捆绑了一个特定于操作系统和体系结构的 python 解释器(也就是说,这不起作用,原因与您通常无法在 MacO 上运行 Windows 可执行文件的原因相同)。

关于Python 与 Java 字节码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68098666/

相关文章:

python - 如何将 angular2 与 jinja2 模板和 flask 结合起来

python - 给定一天,如何获取本周的所有日期时间实例?

python - N-Queens 显示 1 个随机解决方案

python-3.x - 通过 PyInstaller 转换 .exe 后,Chromedriver Manager 下载不起作用

java - Oracle 和 Eclipse 的编译器生成的 java 字节码的差异

java - 如何从已编译的 Java 类/jar 文件中删除方法?

python - python 中是否可以使用循环导入多个文件?

python-3.x - 模块未找到错误 : No module named 'Crypto.Math'

python - 导入错误 : No module named FileDialog - after PyInstaller

java - 运行 Java 字节码