我点击它时,pyinstaller2.0 --noconsole不会运行我的exe

时间:2013-06-08 09:46:29

标签: python pyinstaller

我安装了pyinstaller2.0 **,并在Windows7-64bit操作系统上使用Python 2.7.5 32位。

我正在尝试创建一个没有控制台的应用程序。当我使用--noconsole并点击我生成的.exe时,它无法打开。

如果我使用--console将控制台更改为true,我的应用程序运行正常,但我有一个控制台。

我在这里搜索了几个小时并且google并查看其他教程,我无法找到此问题的任何其他主题。

这是我在批处理文件中编译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

1 个答案:

答案 0 :(得分:0)

如果您从未打开任何GUI窗口或类似的东西,依靠控制台进行用户I / O,以及禁止显示控制台,程序将默默启动(即无需打开)任何窗户),这可能会使它的外观不能运行。

要检查这一点,您有几种选择。

  1. 制作一个只停留一会儿的玩具应用程序(sleep(30)或其他东西)。编译。跑。打开任务管理器并查找它。如果它在那里,我的假设是正确的。
  2. 制作一个玩具应用程序,在某个已知的位置(如桌面)创建文件。编译。跑。如果出现文件,我的假设是正确的。
  3. 制作一个显示对话框的玩具应用程序。编译。跑。如果出现对话框,我的假设是正确的。
  4. 基本上,如果您不想使用控制台,则需要

    1. 与用户交互的一些其他方式,通常是GUI;或
    2. 计划如何运作,而无法向用户查询或显示结果。
    3. TL;博士

      你不能只是摆脱控制台,并期望程序运行不变。它将运行,但无法请求输入或显示结果。没有任何魔法可以让你出现GUI。