Here is what is happening:
- 1 - Freezing with debug=True => Generates the .exe file, runs .exe without windows console appearing. This is fine, but I don't think leaving debug=True is the proper way to do it.
- 2 - Freezing with console=True => Generates the .exe file, but open the windows console when I open the .exe file clicking on the icon. It does not open the windows console when I open the file through the common line.
- 3 - Freezing with console=False and debug=False => Generates the .exe file with no errors but when I "open" the .exe file, nothing shows up. In the command line, it appears that the command was run and nothing happened.
Any idea for why my .exe file is not running properly when generating it with console=False and debug=False in the executable_3.spec file??
by .exe file I mean the dist/executable_package_V3/EXE_NAME.exe
I am creating my executable_3.spec file using pyi-makespec executable_3.py (I'm using Windows 10 and Python 3.7.7, but also tried with Python 3.6.10 and 3.5.6 and obtained the same results.) and then running pyinstaller executable_3.spec
Libraries:
- pyinstaller=4.0.dev0
- pyqt5=5.11.3
After a few changes, this is how my executable_3.spec looks like
My executable_3.spec File:
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
added_files = []
a = Analysis(['src\\executable_3.py'], #executable file path
pathex=['C:\\Users\\MY_NAME\\Documents\\GitHub\\PROJECT_NAME'],
binaries=[],
datas=added_files,
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='EXE_NAME',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False)
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='executable_package_V3')
My executable_3.py file
from GUI import QtCore, QtWidgets, Ui_Dialog #GUI is my UI from Qt Designer
import sys
app = QtCore.QCoreApplication.instance()
if app is None:
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_Dialog()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())