I'm attempting to freeze my Python application and have been running into the same problem when using both Cx_Freeze and Py2Exe. Once I've built/frozen the code I start up the executable and rapidly about a half dozen consoles flash (open and close rapidly in succession) on the screen until my GUI Window (created using PyQt5) opens. Once the GUI Window is open, everything appears to be operating fine.
Note: Dll Files There seems to be a common error around DLL files and I've already included a folder called platforms with the qwindows.dll file, as well as the libEGL.dll file directly in the same folder as the executable. I don't believe this is relevant however as I am able to actually see my initial Widget.
Here is my setup.py file for 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)
Here is my setup.py file for 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,
}
}
)
The problem was that I invoked certain os.system commands before the main event look so prior to actually opening up a pyqt window, several shells were opening and closing in rapid succession.