demian-wolf
demian-wolf

Reputation: 1858

After compilation of any Python program with Nuitka I get "is not a valid win32 application" error

I'm trying to compile my Python project to a Windows executable (.exe) using Nuitka. I get no errors/warnings during the compilation process, but when I'm trying to run the resulting executable I get the "C:\Python34\test.exe is not a valid win32 application" error on Windows XP and a similar one on Windows 10, too). The problem persists even when I compile a "Hello, World!" program. Interesting, that I can easily build and run C++ projects from the Visual Studio IDE on the same PC.

I'm using Windows XP (x32 bits), Python 3.4.0 and Microsoft Visual C++ 2008 Professional.

How can I solve this problem?

Upvotes: 1

Views: 1834

Answers (2)

DoctorG
DoctorG

Reputation: 19

I used tried the first steps from the Nuitka website and had the same with example 1. What I found: example 1 uses --mingw64 as option. python -m nuitka --mingw64 hello.py

In example 2/Use Case 1 there is another option introduced: python -m nuitka --follow-imports program.py

I only copied my hello-code from example 1 (working) and renamed it to program.py (failed - even no executable!). So I am shure, the cause will be the call and not the code. When I entered --mingw64 to the second call it worked. My first thought (I am new to this and no expert for nuitka) is that the second example call implicitly uses gcc. At the first time it asks for installing it and then it seems to use it. The first call seems to force mingw64 as compiler. Could also be that the sequence of path entries makes a difference. Just the first entry will be executed unless you force it via an explicit option.

Upvotes: 0

demian-wolf
demian-wolf

Reputation: 1858

I have installed Microsoft Visual Studio 2010 Express instead of Microsoft Visual Studio 2008 Professional, and the problem disappeared. It looks like Nuitka just can't work with the previous version of the compiler. They even say in the docs, that Nuitka is designed for Visual Studio 2017+ (but I can't install recent versions on Windows XP), and that other versions may not work correctly.

Upvotes: 1

Related Questions