使用PyInstaller和wxPython生成的.exe崩溃

1 投票
2 回答
1750 浏览
提问于 2025-04-15 20:37

我正在尝试在Windows Vista上使用PyInstaller把一个非常简单的wxPython脚本编译成可执行文件。

这个Python脚本就是一个简单的“你好,世界”程序,我想先把它做成Windows的可执行文件,然后再添加其他功能。但我现在遇到了麻烦。

我在处理一些文件时遇到了问题,比如MSVCR90.DLL、MSVCP90.DLL和MSVCPM90.DLL,最后我从我的Visual Studio安装目录里复制了这些文件(C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT)。

按照PyInstaller的说明,我运行了:

Command:
Configure.py

Output:
I: computing EXE_dependencies
I: Finding TCL/TK...
I: could not find TCL/TK
I: testing for Zlib...
I: ... Zlib available
I: Testing for ability to set icons, version resources...
I: ... resource update available
I: Testing for Unicode support...
I: ... Unicode available
I: testing for UPX...
I: ...UPX available
I: computing PYZ dependencies...

到目前为止,一切正常。我继续进行。

Command:
Makespec.py -F guitest.py

Output:
wrote C:\Code\PromoUSB\guitest.spec
now run Build.py to build the executable

然后是最后一个命令。

Command:
Build.py guitest.spec

Output:
checking Analysis
building Analysis because out0.toc non existent
running Analysis out0.toc
Analyzing: C:\Python26\pyinstaller-1.3\support\_mountzlib.py
Analyzing: C:\Python26\pyinstaller-1.3\support\useUnicode.py
Analyzing: guitest.py
Warnings written to C:\Code\PromoUSB\warnguitest.txt
checking PYZ
rebuilding out1.toc because out1.pyz is missing
building PYZ out1.toc
checking PKG
rebuilding out3.toc because out3.pkg is missing
building PKG out3.pkg
checking ELFEXE
rebuilding out2.toc because guitest.exe missing
building ELFEXE out2.toc

我得到了一个名为'guitest.exe'的文件,但运行时它“直接崩溃”了……而且没有任何调试信息。这就像是标准的Windows Vista崩溃。

这个脚本guitest.py单独运行得很好。只有作为可执行文件时崩溃,我完全不知道该怎么办。我甚至不知道该找什么,因为我尝试的都没有得到任何有用的结果。

编译过程中还生成了另一个文件,叫做'warnguitest.txt'。里面的内容是这样的:


W: no module named posix (conditional import by os)
W: no module named optik.__all__ (top-level import by optparse)
W: no module named readline (delayed, conditional import by cmd)
W: no module named readline (delayed import by pdb)
W: no module named pwd (delayed, conditional import by posixpath)
W: no module named org (top-level import by pickle)
W: no module named posix (delayed, conditional import by iu)
W: no module named fcntl (conditional import by subprocess)
W: no module named org (top-level import by copy)
W: no module named _emx_link (conditional import by os)
W: no module named optik.__version__ (top-level import by optparse)
W: no module named fcntl (top-level import by tempfile)
W: __all__ is built strangely at line 0 - collections (C:\Python26\lib\collections.pyc)
W: delayed  exec statement detected at line 0 - collections (C:\Python26\lib\collections.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (C:\Python26\lib\doctest.pyc)
W: delayed  exec statement detected at line 0 - doctest (C:\Python26\lib\doctest.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (C:\Python26\lib\doctest.pyc)
W: delayed  __import__ hack detected at line 0 - encodings (C:\Python26\lib\encodings\__init__.pyc)
W: __all__ is built strangely at line 0 - optparse (C:\Python26\pyinstaller-1.3\optparse.pyc)
W: __all__ is built strangely at line 0 - dis (C:\Python26\lib\dis.pyc)
W: delayed  eval hack detected at line 0 - os (C:\Python26\lib\os.pyc)
W: __all__ is built strangely at line 0 - __future__ (C:\Python26\lib\__future__.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest (C:\Python26\lib\unittest.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest (C:\Python26\lib\unittest.pyc)
W: __all__ is built strangely at line 0 - tokenize (C:\Python26\lib\tokenize.pyc)
W: __all__ is built strangely at line 0 - wx (C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\__init__.pyc)
W: __all__ is built strangely at line 0 - wx (C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\__init__.pyc)
W: delayed  exec statement detected at line 0 - bdb (C:\Python26\lib\bdb.pyc)
W: delayed  eval hack detected at line 0 - bdb (C:\Python26\lib\bdb.pyc)
W: delayed  eval hack detected at line 0 - bdb (C:\Python26\lib\bdb.pyc)
W: delayed  __import__ hack detected at line 0 - pickle (C:\Python26\lib\pickle.pyc)
W: delayed  __import__ hack detected at line 0 - pickle (C:\Python26\lib\pickle.pyc)
W: delayed conditional exec statement detected at line 0 - iu (C:\Python26\pyinstaller-1.3\iu.pyc)
W: delayed conditional exec statement detected at line 0 - iu (C:\Python26\pyinstaller-1.3\iu.pyc)
W: delayed  eval hack detected at line 0 - gettext (C:\Python26\lib\gettext.pyc)
W: delayed  __import__ hack detected at line 0 - optik.option_parser (C:\Python26\pyinstaller-1.3\optik\option_parser.pyc)
W: delayed conditional eval hack detected at line 0 - warnings (C:\Python26\lib\warnings.pyc)
W: delayed conditional __import__ hack detected at line 0 - warnings (C:\Python26\lib\warnings.pyc)
W: __all__ is built strangely at line 0 - optik (C:\Python26\pyinstaller-1.3\optik\__init__.pyc)
W: delayed  exec statement detected at line 0 - pdb (C:\Python26\lib\pdb.pyc)
W: delayed conditional eval hack detected at line 0 - pdb (C:\Python26\lib\pdb.pyc)
W: delayed  eval hack detected at line 0 - pdb (C:\Python26\lib\pdb.pyc)
W: delayed conditional eval hack detected at line 0 - pdb (C:\Python26\lib\pdb.pyc)
W: delayed  eval hack detected at line 0 - pdb (C:\Python26\lib\pdb.pyc)

我对这些内容完全搞不懂。再说一次,我的搜索没有找到任何有用的信息。

2 个回答

0

在Windows系统上,我发现Py2exe更稳定,也更容易使用,你试过这个吗?

0

我在PyInstaller的邮件列表上找到了这个问题的解决办法,方法非常简单,只是没有文档说明。

PyInstaller目前还不支持Python 2.6。解决办法是从一个页面获取一个补丁,这个页面现在可以在我尝试的编译过程中找到,如果你尝试用Python 2.6来编译的话。

不过还是要感谢大家!

补充说明:这个页面以前在 http://svn.pyinstaller.org/branches/py26win 上,但现在已经不存在了。

撰写回答