应用程序在打开前快速打开和关闭多个控制台(PyQt5、Cx_Freeze 和 Py2Exe)

Application Rapidly Opens and Closes Multiple Consoles Before Opening (PyQt5, Cx_Freeze & Py2Exe)

我试图冻结我的 Python 应用程序,并且在同时使用 Cx_Freeze 和 Py2Exe 时 运行 遇到了同样的问题。一旦我 built/frozen 代码启动可执行文件并迅速在屏幕上闪烁大约六个控制台(连续快速打开和关闭),直到我的 GUI Window(使用 PyQt5 创建)打开。打开 GUI Window 后,一切似乎都运行良好。

注:Dll 文件 DLL 文件似乎存在一个常见错误,我已经将名为 platforms 的文件夹与 qwindows.dll 文件以及 libEGL.dll 文件直接包含在与可执行文件相同的文件夹中。但是我不认为这是相关的,因为我能够实际看到我的初始 Widget。

这是我的 setup.py 文件 Cx_Freeze:

import sys
from cx_Freeze import setup, Executable

base = 'Win32GUI'

executables = [
    Executable('__main__.py', base=base)
]

# Dependencies are automatically detected, but it might need fine tuning.
buildOptions = {"packages": [], "excludes": []}
#serial, requests, idna

setup(name = "Test", 
    version = "0.1", 
    description = "Manufacturing Testing Software", 
    options = dict(build_exe = buildOptions),
    executables = executables)

这是我的 setup.py Py2Exe 文件:

from setuptools import setup
import os
import py2exe

includes = ["sip",
            "PyQt5",
            "PyQt5.QtCore",
            "PyQt5.QtGui",
            "PyQt5.QtWidgets",
            "PyQt5.QtWebKit",
            "PyQt5.QtWebKitWidgets",
            "PyQt5.QtWebKitWidgets",
            "PyQt5.QtNetwork",
            "PyQt5.QtPrintSupport"]

datafiles = [("platforms", [r"C:\Users\allan\AppData\Local\Continuum\Anaconda2\Library\plugins\platforms\qwindows.dll"]),
             ("", [r"c:\windows\syswow64\MSVCP100.dll",
                   r"c:\windows\syswow64\MSVCR100.dll",
                   r"C:\Python36-32\Lib\site-packages\PyQt5\Qt\bin\libEGL.dll"])] 



setup(
    name='Test',
    version='1',
    windows=['__main__.py'],
    data_files = datafiles,
    options={
        "py2exe":{
            "includes": includes,
        }
    }
)

问题是我在主事件之前调用了某些 os.system 命令,所以在实际打开 pyqt window 之前,几个 shell 正在快速连续打开和关闭。