5

I'm experimenting with Nuitka on Ubuntu 14.04 and trying to create and run an executable. I have a file hello.py with the contents

print("Hello please")

Which I've turned into hello.exe using the command nuitka hello.py. However, when I try to run it using Wine 1.7, I get get the following error:

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

I think this is a problem with Nuitka, not Wine because I can use Wine to run a helloworld.exe I created in C#. Does anyone know how to fix it?

Edit:

I wasn't having any luck on Ubuntu so I tested out the hello.exe out on my Windows 7 partition (both Ubuntu and Windows are 64-bit) and I got the following error:

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.

Is the problem that Nuitka is creating a 32-bit exe and I'm trying to run it on a 64-bit OS? And if so, anyone know how to fix it?

Charles Clayton
  • 17,005
  • 11
  • 87
  • 120
  • 1
    What do you get if you run `file hello.exe`? – icktoofay Dec 22 '14 at 00:20
  • 2
    @icktoofay `ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=2818f1ff4011ed5d22666d59b490cfac8aef0af9, not stripped` I guess its 64-bit so that can't be the problem. – Charles Clayton Dec 22 '14 at 07:34
  • 4
    From that, I can see that Nuitka is generating a Linux executable. That will of course run on Linux with `./hello.exe`, but because it’s a Linux executable and not a Windows executable, Windows won’t be able to make any sense of it, and neither will Wine. – icktoofay Dec 23 '14 at 22:16
  • Nuitka creates C++ code, so you can get that and compile with your desired compiler/target options. – m3nda Sep 21 '15 at 04:22
  • Wrote a detailed guide on how to do this over at https://ao.gl/how-to-package-a-python-app-using-nuitka/ – AO_ Jul 24 '20 at 00:49

1 Answers1

9

As per the Nuitka manual

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.

If you run nuitka hello.py on Ubuntu (and thusgccELF) you will createhello.exe` BUT an linux-only ELF executable

If you run nuitka hello.py on Windows (and thus gcc/ PE) you will create hello.exe BUT a windows-only PE executable (which could be executed in linux via WINE)

Nuitka, Cython, cx_freeze does not produce an OS agnostic executable, but provides means to build for a particular OS

You are trying todo one of two things 1) build in linux for windows. If this is the case you need to configure cross compiling OR do the final build in WINE (ie install into wine: python, nuitika, gcc...)

2) you build in linux for linux. chmod +x hello.exe; ./hello.exe # and then maybe rename.

Tobias Kienzler
  • 25,759
  • 22
  • 127
  • 221
Naib
  • 999
  • 7
  • 20