1

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

Python 脚本只不过是 wxPython 中的 Hello World。在添加程序所需的任何功能之前,我正在尝试将其作为 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)

我不知道该怎么做。再一次,我的搜索没有结果。

4

2 回答 2

0

在 Windows 上,我发现 Py2exe 更稳定且更易于使用,你试过了吗?

于 2010-03-20T15:49:36.900 回答
0

我在 PyInstaller 邮件列表上找到了这个问题的解决方案,它非常简单,只是没有记录。

PyInstaller 还不支持 Python 2.6。解决方案是从现在可以在我尝试的编译过程中找到的页面获取补丁,如果有人尝试使用 Python 2.6 进行编译。

不过还是谢谢大家!

编辑:该页面曾经托管在http://svn.pyinstaller.org/branches/py26win但它不再存在。

于 2010-03-22T16:10:38.953 回答