PyQt5 Program closes immediately after running compiled EXE



  • This is the first time I have tried compiling a project, I've decided to use PyInstaller. The compiler is successful in building the exe, when it comes to run it in 'normal' mode the program runs until the PyQt5 window opens, in which nothing is displayed only the window outline and the project logo (It can access the resource files) then the application then freezes. However, in debug mode, the output is as below.

    >[21664] PyInstaller Bootloader 3.x                                                                                      
    >[21664] LOADER: executable is PATH\mainGUI (1) (1).exe                      
    >[21664] LOADER: homepath is PATH                                            
    >[21664] LOADER: _MEIPASS2 is NULL                                                                                      
    >[21664] LOADER: archivename is PATH\mainGUI (1) (1).exe                     
    >[21664] LOADER: No need to extract files to run; setting extractionpath to homepath                                     
    >[21664] LOADER: SetDllDirectory(PATH)                                       
    >[21664] LOADER: Already in the child - running user's code.                                                             
    >[21664] LOADER: Python library: PATH\python35.dll                   
    >[21664] LOADER: Loaded functions from Python library.                                                                   
    >[21664] LOADER: Manipulating environment (sys.path, sys.prefix)                                                         
    >[21664] LOADER: sys.prefix is PATH                                   
    >[21664] LOADER: Pre-init sys.path is PATH;PATH                                        
    >[21664] LOADER: Setting runtime options                                                                                 
    >[21664] LOADER: Initializing python                                                                                     
    >[21664] LOADER: Overriding Python's sys.path                                                                            
    >[21664] LOADER: Post-init sys.path is PATH;PATH                                                          
    >[21664] LOADER: Setting sys.argv                                                                                        
    >[21664] LOADER: setting sys._MEIPASS                                                                                    
    >[21664] LOADER: importing modules from CArchive                                                                         
    >[21664] LOADER: extracted struct                                                                                        
    >[21664] LOADER: callfunction returned...                                                                                
    >[21664] LOADER: extracted pyimod01_os_path                                                                              
    >[21664] LOADER: callfunction returned...                                                                                
    >[21664] LOADER: extracted pyimod02_archive                                                                              
    >[21664] LOADER: callfunction returned...                                                                                
    >[21664] LOADER: extracted pyimod03_importers                                                                            
    >[21664] LOADER: callfunction returned...                                                                                
    >[21664] LOADER: Installing PYZ archive with Python modules.                                                             
    >[21664] LOADER: PYZ archive: PYZ-00.pyz                                                                                 
    >[21664] LOADER: Running pyiboot01_bootstrap.py                                                                          
    >[21664] LOADER: Running pyi_rth_multiprocessing.py                                                                      
    >[21664] LOADER: Running pyi_rth_pkgres.py                                                                               
    >[21664] LOADER: Running pyi_rth_qt5.py                                                                                  
    >[21664] LOADER: Running mainGUI.py                                                                                      
    >ENTER NGROK PORT :0                                                                                                 
    >[21664] LOADER: OK.                                                                                                
    >[21664] LOADER: Cleaning up Python interpreter.  
    

    (NGROK PORT :0 is only for connection to a server)

    I have checked for missing DLLs using Dependency Walker and nothing comes up. I am thinking it has to do with a PyQt hook but I am completley lost on what to do.

    Any help would be appreciated.

    I have tried recompiling multiple times with other compilers like py2exe and looking through the trace of OllyDbg but still no luck.

    EDIT Managed to compile a more useful version to debug. Error Message is >QApplication::exec: Must Be called from the main Thread Which is odd as the window is called from the main Thread successfully in IDLE.

    Further but possibly irrelevant digging Looking in OllyDbg comes up with

    0053C9B8 770745F9 RETURN to KERNELBA.770745F9 from ntdll.ZwWaitForSingleObject

    Log data

               New process with ID 000037CC created
    00147BBA   Main thread with ID 000056AC created
    77AB1440   New thread with ID 000055CC created
    77AB1440   New thread with ID 000048E0 created
    77AB1440   New thread with ID 00005128 created
    00140000   Module PATH\ver170219 2\mainGUI.exe
    72260000   Module C:\WINDOWS\SYSTEM32\apphelp.dll
    74310000   Module C:\WINDOWS\System32\CRYPTBASE.dll
    74320000   Module C:\WINDOWS\System32\SspiCli.dll
    75840000   Module C:\WINDOWS\System32\WS2_32.dll
    765B0000   Module C:\WINDOWS\System32\KERNEL32.DLL
    76890000   Module C:\WINDOWS\System32\sechost.dll
    768E0000   Module C:\WINDOWS\System32\RPCRT4.dll
    76F20000   Module C:\WINDOWS\System32\bcryptPrimitives.dll
    76F80000   Module C:\WINDOWS\System32\KERNELBASE.dll
    77A60000   Module C:\WINDOWS\SYSTEM32\ntdll.dll
    77ACCE37   Single step event at ntdll.77ACCE37
    00147BBA   Program entry point
               Analysing mainGUI
                 670 heuristical procedures
                 278 calls to known, 687 calls to guessed functions
                 302 loops, 43 switches
    652E0000   Module PATH\ver170219 2\python35.dll
    76DC0000   Module C:\WINDOWS\System32\ADVAPI32.dll
    75690000   Module C:\WINDOWS\System32\msvcrt.dll
    777C0000   Module C:\WINDOWS\System32\ucrtbase.dll
    74190000   Module C:\WINDOWS\SYSTEM32\VERSION.dll
    6A090000   Module PATH\ver170219 2\VCRUNTIME140.dll
    724C0000   Module C:\WINDOWS\System32\CRYPTSP.dll
    72490000   Module C:\WINDOWS\system32\rsaenh.dll
    73C60000   Module C:\WINDOWS\SYSTEM32\bcrypt.dll
    6D000000   Module PATH\ver170219 2\python3.dll
    6A070000   Module PATH\ver170219 2\_ctypes.pyd
    769F0000   Module C:\WINDOWS\System32\ole32.dll
    76B60000   Module C:\WINDOWS\System32\combase.dll
    766F0000   Module C:\WINDOWS\System32\GDI32.dll
    76430000   Module C:\WINDOWS\System32\gdi32full.dll
    763B0000   Module C:\WINDOWS\System32\msvcp_win.dll
    77170000   Module C:\WINDOWS\System32\USER32.dll
    777A0000   Module C:\WINDOWS\System32\win32u.dll
    75750000   Module C:\WINDOWS\System32\OLEAUT32.dll
    774A0000   Module C:\WINDOWS\System32\IMM32.DLL
    66A60000   Module PATH\ver170219 2\_socket.pyd
    6C290000   Module PATH\ver170219 2\select.pyd
    66A40000   Module PATH\ver170219 2\_bz2.pyd
    66650000   Module PATH\ver170219 2\_lzma.pyd
    66380000   Module PATH\ver170219 2\pyexpat.pyd
    651D0000   Module PATH\ver170219 2\_hashlib.pyd
    65010000   Module PATH\ver170219 2\PyQt5\QtCore.pyd
    64B60000   Module PATH\ver170219 2\Qt5Core.dll
    74340000   Module C:\WINDOWS\System32\SHELL32.dll
    758B0000   Module C:\WINDOWS\System32\cfgmgr32.dll
    75D60000   Module C:\WINDOWS\System32\shcore.dll
    75DF0000   Module C:\WINDOWS\System32\windows.storage.dll
    769A0000   Module C:\WINDOWS\System32\shlwapi.dll
    77960000   Module C:\WINDOWS\System32\kernel.appcore.dll
    758F0000   Module C:\WINDOWS\System32\profapi.dll
                 Invalid or compressed Image Export Directory
    778E0000   Module C:\WINDOWS\System32\powrprof.dll
    765A0000   Module C:\WINDOWS\System32\FLTLIB.DLL
    727F0000   Module C:\WINDOWS\SYSTEM32\MPR.dll
    74170000   Module C:\WINDOWS\SYSTEM32\NETAPI32.dll
    742E0000   Module C:\WINDOWS\SYSTEM32\USERENV.dll
    72C70000   Module C:\WINDOWS\SYSTEM32\WINMM.dll
    64AE0000   Module PATH\ver170219 2\MSVCP140.dll
    726E0000   Module C:\WINDOWS\SYSTEM32\WINMMBASE.dll
    74070000   Module C:\WINDOWS\SYSTEM32\NETUTILS.DLL
    607E0000   Module C:\WINDOWS\SYSTEM32\SRVCLI.DLL
    66630000   Module PATH\ver170219 2\PyQt5\sip.pyd
    64900000   Module PATH\ver170219 2\PyQt5\QtGui.pyd
    64400000   Module PATH\ver170219 2\Qt5Gui.dll
    64050000   Module PATH\ver170219 2\PyQt5\QtWidgets.pyd
    63C10000   Module PATH\ver170219 2\Qt5Widgets.dll
    71DC0000   Module C:\WINDOWS\SYSTEM32\UxTheme.dll
    71FA0000   Module C:\WINDOWS\SYSTEM32\dwmapi.dll
    63AA0000   Module PATH\ver170219 2\_ssl.pyd
    77300000   Module C:\WINDOWS\System32\CRYPT32.dll
    76AF0000   Module C:\WINDOWS\System32\MSASN1.dll
    73500000   Module C:\WINDOWS\system32\mswsock.dll
    639C0000   Module PATH\ver170219 2\unicodedata.pyd
    63870000   Module PATH\ver170219 2\numpy\core\multiarray.cp35-win32.pyd
    04692810   New thread with ID 000054C4 created
    04692810   New thread with ID 00003240 created
    04692810   New thread with ID 00002554 created
    04460000   Module PATH\ver170219 2\libopenblas.KZGMSHIV2CB7DB4HQYDV2LEPUALNSYMY.gfortran-win32.dll
    637C0000   Module PATH\ver170219 2\numpy\core\umath.cp35-win32.pyd
    6C110000   Module PATH\ver170219 2\numpy\linalg\lapack_lite.cp35-win32.pyd
    66360000   Module PATH\ver170219 2\numpy\linalg\_umath_linalg.cp35-win32.pyd
    66320000   Module PATH\ver170219 2\_decimal.pyd
    637A0000   Module PATH\ver170219 2\numpy\core\_multiarray_tests.cp35-win32.pyd
    6BE70000   Module PATH\ver170219 2\numpy\fft\fftpack_lite.cp35-win32.pyd
    636F0000   Module PATH\ver170219 2\numpy\random\mtrand.cp35-win32.pyd
    636C0000   Module PATH\ver170219 2\pandas\_libs\tslib.cp35-win32.pyd
    63680000   Module PATH\ver170219 2\pandas\_libs\tslibs\conversion.cp35-win32.pyd
    66A30000   Module PATH\ver170219 2\pandas\_libs\tslibs\np_datetime.cp35-win32.pyd
    63650000   Module PATH\ver170219 2\pandas\_libs\tslibs\nattype.cp35-win32.pyd
    63600000   Module PATH\ver170219 2\pandas\_libs\tslibs\timedeltas.cp35-win32.pyd
    635E0000   Module PATH\ver170219 2\pandas\_libs\tslibs\timezones.cp35-win32.pyd
    635A0000   Module PATH\ver170219 2\pandas\_libs\tslibs\parsing.cp35-win32.pyd
    63590000   Module PATH\ver170219 2\pandas\_libs\tslibs\ccalendar.cp35-win32.pyd
    63550000   Module PATH\ver170219 2\pandas\_libs\tslibs\strptime.cp35-win32.pyd
    63510000   Module PATH\ver170219 2\pandas\_libs\tslibs\timestamps.cp35-win32.pyd
    634F0000   Module PATH\ver170219 2\pandas\_libs\tslibs\fields.cp35-win32.pyd
    63490000   Module PATH\ver170219 2\pandas\_libs\hashtable.cp35-win32.pyd
    63470000   Module PATH\ver170219 2\pandas\_libs\missing.cp35-win32.pyd
    63410000   Module PATH\ver170219 2\pandas\_libs\lib.cp35-win32.pyd
    63310000   Module PATH\ver170219 2\pandas\_libs\algos.cp35-win32.pyd
    63300000   Module PATH\ver170219 2\pandas\_libs\properties.cp35-win32.pyd
    632F0000   Module PATH\ver170219 2\pandas\_libs\hashing.cp35-win32.pyd
    63290000   Module PATH\ver170219 2\pandas\_libs\index.cp35-win32.pyd
    63250000   Module PATH\ver170219 2\pandas\_libs\tslibs\period.cp35-win32.pyd
    63230000   Module PATH\ver170219 2\pandas\_libs\tslibs\frequencies.cp35-win32.pyd
    63200000   Module PATH\ver170219 2\pandas\_libs\tslibs\resolution.cp35-win32.pyd
    631C0000   Module PATH\ver170219 2\pandas\_libs\tslibs\offsets.cp35-win32.pyd
    63050000   Module PATH\ver170219 2\pandas\_libs\join.cp35-win32.pyd
    63030000   Module PATH\ver170219 2\pandas\_libs\ops.cp35-win32.pyd
    62EC0000   Module PATH\ver170219 2\pandas\_libs\interval.cp35-win32.pyd
    62EB0000   Module PATH\ver170219 2\pandas\_libs\indexing.cp35-win32.pyd
    62E80000   Module PATH\ver170219 2\pandas\_libs\internals.cp35-win32.pyd
    62DE0000   Module PATH\ver170219 2\pandas\_libs\sparse.cp35-win32.pyd
    62D70000   Module PATH\ver170219 2\pandas\_libs\window.cp35-win32.pyd
    62D50000   Module PATH\ver170219 2\pandas\_libs\skiplist.cp35-win32.pyd
    62D10000   Module PATH\ver170219 2\pandas\_libs\reduction.cp35-win32.pyd
    62C90000   Module PATH\ver170219 2\pandas\_libs\groupby.cp35-win32.pyd
    62C70000   Module PATH\ver170219 2\pandas\_libs\reshape.cp35-win32.pyd
    62C10000   Module PATH\ver170219 2\pandas\_libs\parsers.cp35-win32.pyd
    62BF0000   Module PATH\ver170219 2\pandas\_libs\json.cp35-win32.pyd
    62BC0000   Module PATH\ver170219 2\pandas\_libs\writers.cp35-win32.pyd
    62BA0000   Module PATH\ver170219 2\pandas\io\msgpack\_packer.cp35-win32.pyd
    62B80000   Module PATH\ver170219 2\pandas\io\msgpack\_unpacker.cp35-win32.pyd
    62B70000   Module PATH\ver170219 2\pandas\util\_move.cp35-win32.pyd
    62B50000   Module PATH\ver170219 2\pandas\_libs\testing.cp35-win32.pyd
    62B20000   Module PATH\ver170219 2\pyodbc.cp35-win32.pyd
    62A80000   Module C:\WINDOWS\SYSTEM32\ODBC32.dll
    77AB1440   New thread with ID 00004EB0 created
    77AB1440   New thread with ID 00002144 created
    717F0000   Module C:\WINDOWS\SYSTEM32\DPAPI.DLL
    62950000   Module PATH\ver170219 2\PyQt5\Qt\plugins\platforms\qwindows.dll
    62920000   Module PATH\ver170219 2\PyQt5\Qt\plugins\styles\qwindowsvistastyle.dll
    62910000   Module PATH\ver170219 2\PyQt5\Qt\plugins\imageformats\qgif.dll
    62900000   Module PATH\ver170219 2\PyQt5\Qt\plugins\imageformats\qicns.dll
    628F0000   Module PATH\ver170219 2\PyQt5\Qt\plugins\imageformats\qico.dll
    628A0000   Module PATH\ver170219 2\PyQt5\Qt\plugins\imageformats\qjpeg.dll
    62890000   Module PATH\ver170219 2\PyQt5\Qt\plugins\imageformats\qsvg.dll
    62840000   Module PATH\ver170219 2\Qt5Svg.dll
    62830000   Module PATH\ver170219 2\PyQt5\Qt\plugins\imageformats\qtga.dll
    627D0000   Module PATH\ver170219 2\PyQt5\Qt\plugins\imageformats\qtiff.dll
    62700000   Module PATH\ver170219 2\PyQt5\Qt\plugins\imageformats\qwbmp.dll
    62690000   Module PATH\ver170219 2\PyQt5\Qt\plugins\imageformats\qwebp.dll
    6F250000   Module C:\WINDOWS\system32\dwrite.dll
    76BF8010   New thread with ID 0000554C created
    77650000   Module C:\WINDOWS\System32\MSCTF.dll
    77560000   Module C:\WINDOWS\System32\clbcatq.dll
    6BE20000   Module C:\WINDOWS\system32\dataexchange.dll
    6EFF0000   Module C:\WINDOWS\system32\d3d11.dll
    6BCE0000   Module C:\WINDOWS\system32\dcomp.dll
    71EF0000   Module C:\WINDOWS\system32\dxgi.dll
    6C120000   Module C:\WINDOWS\system32\twinapi.appcore.dll
    6CFE0000   Module C:\WINDOWS\system32\RMCLIENT.dll
    6D0C0000   Module C:\WINDOWS\System32\TextInputFramework.dll
    6AA40000   Module C:\WINDOWS\System32\CoreUIComponents.dll
    6ACA0000   Module C:\WINDOWS\System32\CoreMessaging.dll
    734D0000   Module C:\WINDOWS\SYSTEM32\ntmarta.dll
    64B906A0   New thread with ID 00005184 created
               Thread 00005184 terminated, exit code 0
               Thread 00005184 terminated, trace stopped
    

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    How are you building your executable ?
    What version of PyQt5 and Qt are you using ?

    Since you are using PyQt, you might want to consider contacting its authors.