skip to Main Content

I am trying to make a python desktop app with PyQt6. I want to make it into a clickable app by using pyinstaller but I get a "app closed unexpectedly" error when I try to run the app from finder. Equally I cant run the app from terminal either but the app works fine when run through my IDE without pyinstaller.

To test it isnt my app, I have made a fresh environment with different python versions and used the following simple app code from the PyQt website (https://www.pythonguis.com/tutorials/pyqt6-creating-your-first-window/)

Python version 3.9
pyinstaller version 5.13.0
pyqt6 version 6.5.2

When trying to launch the app and it crashes, sending the logs to apple gives a segmentation fault as follows:

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000008
Exception Codes:       0x0000000000000001, 0x0000000000000008

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [26876]

VM Region Info: 0x8 is not in any region.  Bytes before following region: 105553518919672
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-/rwx SM=NUL  ...(unallocated)

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   CoreFoundation                         0x1922c665c _CFGetNonObjCTypeID + 92
1   CoreFoundation                         0x1921982ec CFBundleCopyBundleURL + 24
2   QtCore                                 0x102380a5c QLibraryInfoPrivate::path(QLibraryInfo::LibraryPath, QLibraryInfoPrivate::UsageMode) + 440
3   QtCore                                 0x1023810ac QLibraryInfoPrivate::path(QLibraryInfo::LibraryPath, QLibraryInfoPrivate::UsageMode) + 2056
4   QtCore                                 0x1023b7470 0x102374000 + 275568
5   QtCore                                 0x1023b6a6c 0x102374000 + 273004
6   QtCore                                 0x1023b8fd4 0x102374000 + 282580
7   QtCore                                 0x1023b5c58 QLoggingCategory::QLoggingCategory(char const*, QtMsgType) + 52
8   QtCore.abi3.so                         0x10509cde0 warmUpLocationServices() + 268
9   QtCore.abi3.so                         0x10509f724 _GLOBAL__sub_I_qdarwinpermissionplugin_location.mm + 12
10  dyld                                   0x191dd81d8 invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const::$_0::operator()() const + 168
11  dyld                                   0x191e19c60 invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 172
12  dyld                                   0x191e0d1a4 invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 528
13  dyld                                   0x191db82d8 dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 296
14  dyld                                   0x191e0c1cc dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 192
15  dyld                                   0x191e0ecfc dyld3::MachOFile::forEachInitializerPointerSection(Diagnostics&, void (unsigned int, unsigned int, bool&) block_pointer) const + 160
16  dyld                                   0x191e19904 dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 432
17  dyld                                   0x191dd485c dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 448
18  dyld                                   0x191dd4c10 dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 220
19  dyld                                   0x191dd8264 dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const::$_1::operator()() const + 112
20  dyld                                   0x191dd4d90 dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const + 304
21  dyld                                   0x191df2d58 dyld4::APIs::dlopen_from(char const*, int, void*) + 1440
22  libpython3.10.dylib                    0x100dfa844 _PyImport_FindSharedFuncptr + 296
23  libpython3.10.dylib                    0x100db599c _imp_create_dynamic + 1108
24  libpython3.10.dylib                    0x100ced0fc cfunction_vectorcall_FASTCALL + 200
25  libpython3.10.dylib                    0x100d847dc _PyEval_EvalFrameDefault + 27276
26  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
27  libpython3.10.dylib                    0x100d886d4 call_function + 524
28  libpython3.10.dylib                    0x100d84464 _PyEval_EvalFrameDefault + 26388
29  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
30  libpython3.10.dylib                    0x100d886d4 call_function + 524
31  libpython3.10.dylib                    0x100d8443c _PyEval_EvalFrameDefault + 26348
32  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
33  libpython3.10.dylib                    0x100d886d4 call_function + 524
34  libpython3.10.dylib                    0x100d844d4 _PyEval_EvalFrameDefault + 26500
35  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
36  libpython3.10.dylib                    0x100d886d4 call_function + 524
37  libpython3.10.dylib                    0x100d844d4 _PyEval_EvalFrameDefault + 26500
38  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
39  libpython3.10.dylib                    0x100d886d4 call_function + 524
40  libpython3.10.dylib                    0x100d844d4 _PyEval_EvalFrameDefault + 26500
41  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
42  libpython3.10.dylib                    0x100c9b894 object_vacall + 272
43  libpython3.10.dylib                    0x100c9bab4 _PyObject_CallMethodIdObjArgs + 128
44  libpython3.10.dylib                    0x100db1a28 PyImport_ImportModuleLevelObject + 1284
45  libpython3.10.dylib                    0x100d770b4 builtin___import__ + 124
46  libpython3.10.dylib                    0x100cec3a0 cfunction_call + 80
47  libpython3.10.dylib                    0x100c9998c _PyObject_MakeTpCall + 612
48  libpython3.10.dylib                    0x100c9ac48 _PyObject_CallFunctionVa + 776
49  libpython3.10.dylib                    0x100c9a918 PyObject_CallFunction + 64
50  libpython3.10.dylib                    0x100db13e8 PyImport_Import + 552
51  libpython3.10.dylib                    0x100db27e0 PyImport_ImportModule + 60
52  sip.cpython-310-darwin.so              0x100be1754 sip_api_export_module + 88
53  QtWidgets.abi3.so                      0x1017c1188 PyInit_QtWidgets + 276
54  libpython3.10.dylib                    0x100db59ec _imp_create_dynamic + 1188
55  libpython3.10.dylib                    0x100ced0fc cfunction_vectorcall_FASTCALL + 200
56  libpython3.10.dylib                    0x100d847dc _PyEval_EvalFrameDefault + 27276
57  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
58  libpython3.10.dylib                    0x100d886d4 call_function + 524
59  libpython3.10.dylib                    0x100d84464 _PyEval_EvalFrameDefault + 26388
60  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
61  libpython3.10.dylib                    0x100d886d4 call_function + 524
62  libpython3.10.dylib                    0x100d8443c _PyEval_EvalFrameDefault + 26348
63  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
64  libpython3.10.dylib                    0x100d886d4 call_function + 524
65  libpython3.10.dylib                    0x100d844d4 _PyEval_EvalFrameDefault + 26500
66  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
67  libpython3.10.dylib                    0x100d886d4 call_function + 524
68  libpython3.10.dylib                    0x100d844d4 _PyEval_EvalFrameDefault + 26500
69  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
70  libpython3.10.dylib                    0x100d886d4 call_function + 524
71  libpython3.10.dylib                    0x100d844d4 _PyEval_EvalFrameDefault + 26500
72  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
73  libpython3.10.dylib                    0x100c9b894 object_vacall + 272
74  libpython3.10.dylib                    0x100c9bab4 _PyObject_CallMethodIdObjArgs + 128
75  libpython3.10.dylib                    0x100db1a28 PyImport_ImportModuleLevelObject + 1284
76  libpython3.10.dylib                    0x100d770b4 builtin___import__ + 124
77  libpython3.10.dylib                    0x100cec3a0 cfunction_call + 80
78  libpython3.10.dylib                    0x100c9a3a0 _PyObject_Call + 148
79  libpython3.10.dylib                    0x100d847dc _PyEval_EvalFrameDefault + 27276
80  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
81  libpython3.10.dylib                    0x100d886d4 call_function + 524
82  libpython3.10.dylib                    0x100d844d4 _PyEval_EvalFrameDefault + 26500
83  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
84  libpython3.10.dylib                    0x100c9b894 object_vacall + 272
85  libpython3.10.dylib                    0x100c9bab4 _PyObject_CallMethodIdObjArgs + 128
86  libpython3.10.dylib                    0x100db1ba0 PyImport_ImportModuleLevelObject + 1660
87  libpython3.10.dylib                    0x100d82b40 _PyEval_EvalFrameDefault + 19952
88  libpython3.10.dylib                    0x100d7d444 _PyEval_Vector + 2056
89  libpython3.10.dylib                    0x100d7cc0c PyEval_EvalCode + 120
90  main                                   0x10074c8ec 0x100748000 + 18668
91  main                                   0x10074cf10 0x100748000 + 20240
92  dyld                                   0x191dbbf28 start + 2236

I have tried other frameworks such as py2app, changing pyqt versions, changing python versions, running on a ubuntu machine (new OS) on aws and tried on a different mac device and still no luck. I have also tried all the different flags from pyinstaller e.g --onefile and --onedir. I have also seen and tried the stack overflow suggestion to use the dev version of pyinstaller but this did not resolve the issue. Any help would be massively appreciated – thanks in advance!

2

Answers


  1. Chosen as BEST ANSWER

    After much searching, the key term that led me to the answer ended up being the Segmentation fault: 11. Once this was found then the fix that worked for me came from the following post (https://github.com/pyinstaller/pyinstaller/issues/7789) which was:

    pip uninstall pyinstaller
    PYINSTALLER_COMPILE_BOOTLOADER=1 pip install git+https://github.com/pyinstaller/pyinstaller.git@develop
    

    I hope this helps if anyone else runs into the same issue!


  2. Thank you! Its works for me!
    I spent 5 hours to solve this problem. Thank you friend!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search