For a hierarchical project, the EXE file generated by "pyinstaller" does not start.

Mohsen Owzar mohsen.owzar at gmail.com
Mon Dec 6 23:58:57 EST 2021


Hi all, 

I have a problem with "pyinstaller".
When I compile a single Python file, an EXE file is created in the "dist" directory, with which I can start the program and the GUI appears after a few seconds.
But when I try to compile my project with "pyinstaller Relais_LastDauerTester.py" and generate an EXE file from it, an ".exe" file is also created in the "dist" directory, but nothing happens when I run both .exe files from Windows Explorer with a double click or from the DOS shell by invoking it.
The mouse pointer changes briefly to an hourglass and then back and nothing happens.
The only difference between these two programs is that the first is just a single file and my project is structured hierarchically. I tried to demonstrate the structure of the project below with two "DIR" DOS commands.
In PyCharm you only need to run the top file "Relais_LastDauerTester.py", so I used this file for "pyinstaller".
But it looks like I have to give (I believe) an extra argument for a hierarchical project.
I googled all weekend to find a workable solution. But all I found was for converting a ".py" file and not a project like mine.
With some suggestions, I should add a "pause" or "input ()" command to the code to prevent the DOS shell from disappearing quickly, which is out of the question for me.
Do you have any idea what it could be?
I thank you in advance for any useful advice that could help me.

Greeting
Mohsen

PS 
I work on a PC with 
1201 INFO: PyInstaller: 4.7 
1202 INFO: Python: 3.9.5 
1282 INFO: Platform: Windows-10-10.0.18363-SP0 

Project Structure from PyCharm
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 
...\SW\Relais_LastDauerTester_V0.5 
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 
<DIR> .idea 
<DIR> Logfiles 
<DIR> Relais_LastDauerTester 
276     Relais_LastDauerTester.py 
<DIR> Screenshotfiles 
405     settings.ini 

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 
...\SW\Relais_LastDauerTester_V0.5\Relais_LastDauerTester 
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 
9’308      GPIOControl.py 
90’618   GUI_View.py 
998         main.py 
28’625  TestControl.py 
269      __init__.py 
<DIR>   __pycache__ 


Simplified project files with the "import" lines ******************************************************************* 
Relais_LastDauerTester.py.py 
******************************************************************* 
#!/usr/bin/env python3 
# -*- coding: utf-8 -*- 
from Relais_LastDauerTester.main import main 

if __name__ == "__main__": 
main() 

******************************************************************* 
main.py 
******************************************************************* 
import sys 

from PyQt5.QtCore import * 
from PyQt5.QtWidgets import QApplication 
from .GUI_View import MainWindow 

def main(): 
app = QApplication(sys.argv) 

window = MainWindow() 
window.show() 

sys.exit(app.exec_()) 

if __name__ == '__main__': 
main() 

******************************************************************* 
GUI_View.py 
******************************************************************* 
import sys 
import subprocess 

import PyQt5.QtGui as qtg 
from PyQt5.QtWidgets import (QLabel, QPushButton, QLineEdit, QCheckBox, QWidget, 
QVBoxLayout, QHBoxLayout, QGridLayout, QDialog, QFileDialog) 
from .TestControl import * 

class MainWindow(QWidget): 
def __init__(self): 
super().__init__() 

def createMainWindow(self): 
... 

def exitMainWindow(self): 
... 

def ChangeToPrefWindow(self): 
self.prefwindow.show() 
self.hide() 

class PrefWindow(QWidget): 
def __init__(self, parent=None): 
super().__init__() 
self.parent = parent 
... 
self.createPrefWindow() 

def ChangeToMainWindow(self): 
... 

def createPrefWindow(self): 
... 

class CustomLineEdit(QLineEdit): 
clicked = pyqtSignal() 

def mousePressEvent(self, QMouseEvent): 
self.clicked.emit() 

class Keypad_Window_New(QDialog): 
def __init__(self, num=0, parent=None): 
super().__init__(parent) 
self.parent = parent 
... 

TestContrl.py 
******************************************************************* 
from PyQt5.QtCore import * 
from .GPIOControl import GPIOControl 

class WorkerSignals(QObject): 
signal_Update_Label = pyqtSignal() 

class TestControl(QRunnable): 
signals = WorkerSignals() 

def __init__(self, parent=None): 
super().__init__() 
self.parent = parent 
... 

******************************************************************* 
GPIOContrl.py 
******************************************************************* 
class GPIOControl: 
def my_print(self, args): 
if print_allowed == 1: 
print(args) 

def __init__(self):


More information about the Python-list mailing list