Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
259 views
in Technique[技术] by (71.8m points)

python - Py2Exe: DLL load failed

When trying to use py2exe to convert a simple Python game I made into exe format, it gave me the following error:

Traceback (most recent call last):
  File "C:UsersTaliDesktop2exe.py", line 4, in <module>
    setup(console=['test.py'])
  File "C:Pythonlibdistutilscore.py", line 152, in setup
    dist.run_commands()
  File "C:Pythonlibdistutilsdist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:Pythonlibdistutilsdist.py", line 972, in run_command
    cmd_obj.run()
  File "C:Pythonlibsite-packagespy2exeuild_exe.py", line 243, in run
    self._run()
  File "C:Pythonlibsite-packagespy2exeuild_exe.py", line 305, in _run
    dlls = self.find_dlls(extensions)
  File "C:Pythonlibsite-packagespy2exeuild_exe.py", line 389, in find_dlls

    self.dll_excludes)
  File "C:Pythonlibsite-packagespy2exeuild_exe.py", line 1021, in find_dep
endend_dlls
    import py2exe_util
ImportError: DLL load failed: %1 is not a valid Win32 application.

I searched the web for about an hour, tried changing things in my program. Nothing works. Although my program uses the "random" library, I haven't seen a case in which it caused this kind of problem.

The install script:

from distutils.core import setup
import py2exe

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

Yes, both the scripts are in the same folder (Desktop). If it matters, I'm running on Windows Vista with Python 2.7

Thank you all very much in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had exact the same problem.

Since I have windows 7 64bit, I downloaded py2exe-0.6.9.win64-py2.6.amd64.exe, which I suppose to be the 64bit version of py2exe. but it did not work, and I had the same error.

I changed to py2exe-0.6.9.win32-py2.6.exe, and it worked fine.

I guess you have to match the 32bit or 64bit with the python installation instead of the windows itself.

by the way, "setup.py py2exe" or "python setup.py py2exe" really does not matter, if you instructed windows to open *.py with python during the python installation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...