mtrc
mtrc

Reputation: 1345

Python And Py2Exe: "%1 Is Not A Valid Win32 Application"

I'm trying to compile a python project into an executable. To test this, I've got Py2Exe installed, and am trying to do their Hello.py test. Here is hello.py:

print "Hello World!"

Here is my setup.py:

from distutils.core import setup
import py2exe

setup(console=['hello.py'])

I do the following on the command line:

python setup.py py2exe

And I get it mostly working until it start 'finding dlls needed', at which point we get:

Traceback:
<some trace>
ImportError: DLL load failed: %1 is not a valid Win32 application.

Python version is 2.6.6, and I'm on a 32-bit machine running Windows 7. Any ideas or help most appreciated.

Upvotes: 2

Views: 10015

Answers (3)

Spencer Bates
Spencer Bates

Reputation: 237

I had this same problem, this is what I was able to do Q-A. Basically, I downloaded the updated sqlite dll file from sqlite.org. I replaced the py2exe generated DLL file with this new file. The program worked after that. Do make sure you download the 32-bit DLL, however.

Upvotes: 0

wim
wim

Reputation: 362507

In my experience py2exe is rather difficult to use, a bit hit-and-miss in terms of whether it will work or not, and an absolute nightmare to get working at all with any matplotlib import.

I realise this question is quite old now, but I am not sure why people continue to use py2exe when there are much smoother functioning alternatives available. I have have good results with pyinstaller (which was recommended to me after asking a question here on SO where I was also battling with py2exe). Now every time I have tried it it "just worked", so if you're still interested in packing up python code into executables then try give this app a shot instead.

http://www.pyinstaller.org/

Note: py2exe hasn't been updated for some years, while python and 3rd party modules have, which must be partly why it often doesn't work particularly well these days.

Upvotes: 1

michaelv
michaelv

Reputation: 9

Sounds like step 5 in this tutorial describes what you are experiencing:

http://www.py2exe.org/index.cgi/Tutorial#Step5

Upvotes: 0

Related Questions