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.

3
  • 1
    possible duplicate of Py2Exe: DLL load failed Commented Nov 9, 2010 at 10:27
  • I've tried the suggested solutions; no dice unfortunately. Commented Nov 9, 2010 at 10:32
  • Try to find which DLL is missing thanks to a tool like dependencywalker.com Commented Nov 9, 2010 at 12:54

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

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

1 Comment

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?
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.