Python:使用Pyinstaller编译

5 投票
1 回答
2468 浏览
提问于 2025-04-16 15:00

我正在尝试用Pyinstaller创建一个可执行的二进制文件。在构建这个文件时,出现了一个名为'warnpython.txt'的警告文件,里面有一些信息。

W: no module named msvcrt (conditional import by subprocess)
W: no module named msvcrt (delayed import by getpass)
W: no module named rourl2path (conditional import by urllib)
W: no module named msvcrt (conditional import by getpass)
W: no module named _subprocess (conditional import by subprocess)
W: no module named AES (delayed, conditional import by archive)
W: no module named _scproxy (conditional import by urllib)
W: no module named org (top-level import by pickle)
W: no module named EasyDialogs (conditional import by getpass)
W: no module named SOCKS (top-level import by ftplib)
W: no module named _winreg (delayed import by urllib)
W: no module named nt (top-level import by ntpath)
W: no module named org (top-level import by copy)
W: no module named _emx_link (conditional import by os)
W: __all__ is built strangely at line 0 - __future__ (/usr/lib/python2.6/__future__.pyc)
W: __all__ is built strangely at line 0 - collections (/usr/lib/python2.6/collections.pyc)
W: delayed  exec statement detected at line 0 - collections (/usr/lib/python2.6/collections.pyc)
W: delayed  __import__ hack detected at line 0 - email (/usr/lib/python2.6/email/__init__.pyc)
W: delayed  __import__ hack detected at line 0 - encodings (/usr/lib/python2.6/encodings/__init__.pyc)
W: delayed  __import__ hack detected at line 0 - optparse (/usr/lib/python2.6/optparse.pyc)
W: delayed  exec statement detected at line 0 - socket (/usr/lib/python2.6/socket.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (/usr/lib/python2.6/doctest.pyc)
W: delayed  exec statement detected at line 0 - doctest (/usr/lib/python2.6/doctest.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (/usr/lib/python2.6/doctest.pyc)
W: __all__ is built strangely at line 0 - dis (/usr/lib/python2.6/dis.pyc)
W: delayed  eval hack detected at line 0 - os (/usr/lib/python2.6/os.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest (/usr/lib/python2.6/unittest.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest (/usr/lib/python2.6/unittest.pyc)
W: __all__ is built strangely at line 0 - tokenize (/usr/lib/python2.6/tokenize.pyc)
W: delayed  exec statement detected at line 0 - bdb (/usr/lib/python2.6/bdb.pyc)
W: delayed  eval hack detected at line 0 - bdb (/usr/lib/python2.6/bdb.pyc)
W: delayed  eval hack detected at line 0 - bdb (/usr/lib/python2.6/bdb.pyc)
W: delayed  __import__ hack detected at line 0 - pickle (/usr/lib/python2.6/pickle.pyc)
W: delayed  __import__ hack detected at line 0 - pickle (/usr/lib/python2.6/pickle.pyc)
W: delayed conditional exec statement detected at line 0 - iu (/home/zack/Desktop/pyinstaller-1.5-rc1/iu.pyc)
W: delayed conditional exec statement detected at line 0 - iu (/home/zack/Desktop/pyinstaller-1.5-rc1/iu.pyc)
W: delayed  eval hack detected at line 0 - gettext (/usr/lib/python2.6/gettext.pyc)
W: delayed conditional eval hack detected at line 0 - warnings (/usr/lib/python2.6/warnings.pyc)
W: delayed conditional __import__ hack detected at line 0 - warnings (/usr/lib/python2.6/warnings.pyc)
W: delayed  exec statement detected at line 0 - pdb (/usr/lib/python2.6/pdb.pyc)
W: delayed conditional eval hack detected at line 0 - pdb (/usr/lib/python2.6/pdb.pyc)
W: delayed  eval hack detected at line 0 - pdb (/usr/lib/python2.6/pdb.pyc)
W: delayed conditional eval hack detected at line 0 - pdb (/usr/lib/python2.6/pdb.pyc)
W: delayed  eval hack detected at line 0 - pdb (/usr/lib/python2.6/pdb.pyc)

当我直接运行新生成的可执行文件时,它会让我回到终端,就好像这个程序已经结束了一样。通过直接运行.py脚本测试时,一切都正常,只有在用Pyinstaller编译后才会出现这个问题。这个警告文件有没有给我们一些线索呢?

1 个回答

2

看起来你的系统缺少 pywin32 这个模块。你可以尝试安装 ActivePython,或者直接安装 pywin32 模块。

http://python.net/crew/mhammond/win32/Downloads.html

撰写回答