2

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.

mtrc
  • 1,317
  • 3
  • 16
  • 39

3 Answers3

1

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.

wim
  • 338,267
  • 99
  • 616
  • 750
0

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.

Community
  • 1
  • 1
Spencer Bates
  • 237
  • 3
  • 11
0

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

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

michaelv
  • 9
  • 2
  • I've looked into it but as far as I can tell I have the redistributable installed on my machine. That means it should at least compile, even if it doesn't actually ship with the DLL. No? – mtrc Nov 09 '10 at 12:30