在 exe 为 运行 时退出 cmd

Quit cmd while exe is running

我有一个 .exe (PyQt5 + python3),问题是当我启动应用程序时,cmd window 总是在后台初始化。 我希望 cmd window 未初始化。

这是我用来转换成.exe的代码:

import cx_Freeze
from cx_Freeze import *

setup(
    name = "interfaz",
    options = {'build_exe': {'packages': ['cv2', 'numpy']}},
    executables=[
        Executable(
            "interfaz.py",
        )
    ]
)

这是应用程序的图片:

根据cx_Freezedocumentation,为了避免在Windows下短暂出现命令提示符,你需要:

Freeze your application with the Win32GUI base [...]. This doesn’t use a console window, and reports errors in a dialog box.

尝试这样修改您的安装脚本:

import sys
from cx_Freeze import setup, Executable

# GUI applications require a different base on Windows (the default is for a console application).
base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(name="interfaz",
      options={'build_exe': {'packages': ['cv2', 'numpy']}},
      executables=[Executable("interfaz.py", base=base)])