python - 如何运行 Nuitka 编译的 Python 可执行文件

标签 python ubuntu wine nuitka

我正在试验 Nuitka在 Ubuntu 14.04 上并尝试创建和运行可执行文件。我有一个包含内容的文件 hello.py

print("Hello please")

我使用命令 nuitka hello.py 将其转换为 hello.exe。但是,当我尝试使用 Wine 1.7 运行它时,出现以下错误:

$ wine hello.exe
wine: Bad EXE format for Z:\home\crclayton\hello.exe.

我认为这是 Nuitka 的问题,而不是 Wine,因为我可以使用 Wine 来运行我在 C# 中创建的 helloworld.exe。有谁知道如何修复它?

编辑:

我在 Ubuntu 上运气不好,所以我在我的 Windows 7 分区(Ubuntu 和 Windows 都是 64 位)上测试了 hello.exe,我得到了以下错误:

The version of this file is not compatible with the version of windows you're running. Check your computer's system information to see whether you need an x86 (32 bit) or x64 (64 bit) version of the program, and then contact the software publisher.

问题是 Nuitka 正在创建 32 位 exe 而我试图在 64 位操作系统上运行它吗?如果是这样,有人知道如何解决吗?

最佳答案

根据 Nuitka 手册

The resulting filename will be program.exe on all platforms, that doesn't mean it doesn't run on non-Windows! But if you compile program we wouldn't want to overwrite it, or be unsure which one is the compiled form, and which one is not.

如果您在 Ubuntu 上运行 nuitka hello.py(因此gccELF),您将创建hello.exe` 但它是一个仅限 linux 的 ELF 可执行文件

如果您在 Windows 上运行 nuitka hello.py(并因此运行 gcc/PE),您将创建 hello.exe 但是一个仅限 Windows 的 PE 可执行文件(可能是通过 WINE 在 linux 中执行)

Nuitka、Cython、cx_freeze 不生成与操作系统无关的可执行文件,但提供为特定操作系统构建的方法

你正在尝试做两件事中的一件 1) 在 linux for windows 中构建。如果是这种情况,您需要配置交叉编译或在 WINE 中进行最终构建(即安装到 wine 中:python、nuitika、gcc...)

2) 你在 linux 中为 linux 构建。 chmod +x hello.exe; ./hello.exe # 然后重命名。

关于python - 如何运行 Nuitka 编译的 Python 可执行文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27594776/

相关文章:

python - linux/wine/python-os 参数忽略错误

python - 在python中检测程序

c++ - 如何在Linux/Mac上调用特定的EXE函数

python - Scrapy 分页时间错误

python - pandas:如何生成新列以获取另一列的最后日期时间值

mongodb - 通过ssh启动时Docker容器mongod错误

ubuntu - 如何从 zsh 终端终止在端口中运行的进程

python - Pylint 和 Tornado - 在 @tornado.web.authenticated 上失败

python - Django-rest-framework 与 django OAuth 2.0 提供身份验证错误

ubuntu - 在 Ubuntu 中将 CELERY 作为守护进程运行