exe运行时退出cmd

时间:2019-01-08 09:21:56

标签: cx-freeze

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

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

import cx_Freeze
from cx_Freeze import *

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

这是显示该应用程序的图像:

1 个答案:

答案 0 :(得分:1)

根据cx_Freeze documentation,为避免命令提示符在Windows下短暂出现,您需要:

  

Win32GUI为基础的[...]冻结您的应用程序。这不使用控制台窗口,而是在对话框中报告错误。

请尝试如下修改您的设置脚本:

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)])
相关问题