我已经安装了pyinstaller2.0**,并且在Windows7-64位操作系统上使用Python 2.7.5 32位。
我正在尝试创建一个没有控制台的应用程序。当我使用--noconsole
并单击我生成的.exe
时,它不会打开。
如果我使用--console
将控制台更改为true,那么我的应用程序运行良好,但我有一个控制台。
我已经在这里和谷歌搜索了几个小时,并查看了其他教程,但我找不到这个问题的任何其他线索。
这是我用于编译EXE的批处理文件中的内容
c:\python27_32\python.exe pyinstaller.py --onefile --noconsole c:\python27_32\tutorial5.py
这是我的警告文件;
W: no module named posix (conditional import by os)
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 __main__)
W: no module named posix (delayed, conditional import by iu)
W: no module named Crypt (delayed, conditional import by __main__)
W: no module named fcntl (conditional import by subprocess)
W: no module named AES (delayed, conditional import by __main__)
W: no module named org (top-level import by copy)
W: no module named _emx_link (conditional import by os)
W: no module named fcntl (top-level import by tempfile)
W: no module named AES (delayed, conditional import by archive)
W: __all__ is built strangely at line 0 - collections (c:\python27_32\lib\collections.pyc)
W: delayed exec statement detected at line 0 - collections (c:\python27_32\lib\collections.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.main (c:\python27_32\lib\unittest\main.pyc)
W: __all__ is built strangely at line 0 - dis (c:\python27_32\lib\dis.pyc)
W: delayed __import__ hack detected at line 0 - encodings (c:\python27_32\lib\encodings\__init__.pyc)
W: delayed __import__ hack detected at line 0 - optparse (c:\python27_32\lib\optparse.pyc)
W: delayed __import__ hack detected at line 0 - ctypes (c:\python27_32\lib\ctypes\__init__.pyc)
W: delayed __import__ hack detected at line 0 - ctypes (c:\python27_32\lib\ctypes\__init__.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.loader (c:\python27_32\lib\unittest\loader.pyc)
W: delayed conditional __import__ hack detected at line 0 - unittest.loader (c:\python27_32\lib\unittest\loader.pyc)
W: delayed __import__ hack detected at line 0 - unittest.loader (c:\python27_32\lib\unittest\loader.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (c:\python27_32\lib\doctest.pyc)
W: delayed exec statement detected at line 0 - doctest (c:\python27_32\lib\doctest.pyc)
W: delayed conditional __import__ hack detected at line 0 - doctest (c:\python27_32\lib\doctest.pyc)
W: delayed exec statement detected at line 0 - pdb (c:\python27_32\lib\pdb.pyc)
W: delayed conditional eval hack detected at line 0 - pdb (c:\python27_32\lib\pdb.pyc)
W: delayed eval hack detected at line 0 - pdb (c:\python27_32\lib\pdb.pyc)
W: delayed conditional eval hack detected at line 0 - pdb (c:\python27_32\lib\pdb.pyc)
W: delayed eval hack detected at line 0 - pdb (c:\python27_32\lib\pdb.pyc)
W: __all__ is built strangely at line 0 - __future__ (c:\python27_32\lib\__future__.pyc)
W: __all__ is built strangely at line 0 - hashlib (c:\python27_32\lib\hashlib.pyc)
W: __all__ is built strangely at line 0 - tokenize (c:\python27_32\lib\tokenize.pyc)
W: __all__ is built strangely at line 0 - tokenize (c:\python27_32\lib\tokenize.pyc)
W: __all__ is built strangely at line 0 - wx (c:\python27_32\lib\site-packages\wx-2.8-msw-unicode\wx\__init__.pyc)
W: __all__ is built strangely at line 0 - wx (c:\python27_32\lib\site-packages\wx-2.8-msw-unicode\wx\__init__.pyc)
W: delayed exec statement detected at line 0 - bdb (c:\python27_32\lib\bdb.pyc)
W: delayed eval hack detected at line 0 - bdb (c:\python27_32\lib\bdb.pyc)
W: delayed eval hack detected at line 0 - bdb (c:\python27_32\lib\bdb.pyc)
W: delayed __import__ hack detected at line 0 - pickle (c:\python27_32\lib\pickle.pyc)
W: delayed __import__ hack detected at line 0 - pickle (c:\python27_32\lib\pickle.pyc)
W: delayed conditional exec statement detected at line 0 - iu (C:\pyinstaller\PyInstaller\loader\iu.pyc)
W: delayed conditional exec statement detected at line 0 - iu (C:\pyinstaller\PyInstaller\loader\iu.pyc)
W: delayed eval hack detected at line 0 - gettext (c:\python27_32\lib\gettext.pyc)
W: delayed conditional eval hack detected at line 0 - warnings (c:\python27_32\lib\warnings.pyc)
W: delayed conditional __import__ hack detected at line 0 - warnings (c:\python27_32\lib\warnings.pyc)
这是我的spec文件输出;
# -*- mode: python -*-
a = Analysis(['c:\\python27_32\\tutorial5.py'],
pathex=['C:\\pyinstaller'],
hiddenimports=[],
hookspath=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name=os.path.join('dist', 'tutorial5.exe'),
debug=False,
strip=None,
upx=True,
console=True )
app = BUNDLE(exe,
name=os.path.join('dist', 'tutorial5.exe.app'))
如果我有控制台,一切都很好,但是如果我不想要控制台,什么都不会发生。
我是不是明显漏掉了什么?
我很感谢你的帮助。
Vinster
发布于 2013-06-08 10:01:23
如果您从不打开任何图形用户界面窗口或任何类似的东西,依赖于用户I/O的控制台,和抑制控制台的出现,程序将静默启动(即,不打开任何窗口),这可能会使它看起来没有运行。
要检查这一点,您有几个选项。
sleep(30)
或其他东西)。编译。跑。打开任务管理器并查找它。如果它存在,那么我的假设是正确的。基本上,如果您不想为控制台而烦恼,您需要
tl;dr
您不能简单地摆脱控制台,并期望一个程序不变地运行。它将运行,但不能请求输入或显示结果。没有什么魔法可以让GUI出现在你面前。
https://stackoverflow.com/questions/16998222
复制