英文:
PyQt6 pyinstaller app builds but wont open MacOS (M1 chip)
问题
我正在尝试使用PyQt6制作一个Python桌面应用程序。我想通过使用pyinstaller将其制作成一个可点击的应用程序,但是当我尝试从Finder运行应用程序时,出现了“应用程序意外关闭”的错误。同样,我也无法从终端运行应用程序,但是在没有pyinstaller的情况下通过我的IDE运行应用程序时,应用程序可以正常工作。
为了测试是否是我的应用程序的问题,我创建了一个新的环境,使用不同版本的Python,并使用了来自PyQt网站的以下简单应用程序代码(https://www.pythonguis.com/tutorials/pyqt6-creating-your-first-window/)
Python版本:3.9
pyinstaller版本:5.13.0
pyqt6版本:6.5.2
尝试启动应用程序并出现崩溃时,将日志发送给苹果会显示以下分段错误:
异常类型:EXC_BAD_ACCESS(SIGSEGV)
异常代码:KERN_INVALID_ADDRESS at 0x0000000000000008
异常代码:0x0000000000000001,0x0000000000000008
终止原因:命名空间SIGNAL,代码11 分段错误:11
终止进程:exc handler [26876]
VM区域信息:0x8不在任何区域中。在以下区域之前的字节:105553518919672
区域类型 起始 - 结束 [VSIZE] PRT/MAX SHRMOD REGION DETAIL
启动时未使用的空间
--->
MALLOC_NANO(保留)600018000000-600020000000 [128.0M] rw-/rwx SM=NUL ...(未分配)
线程0崩溃::主线程分派队列: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
...
(以下是长长的错误堆栈,省略部分)
我已经尝试过其他框架,如py2app,更改pyqt版本,更改python版本,在AWS上运行一个新的Ubuntu机器上(新操作系统),并尝试在不同的Mac设备上运行,但仍然没有成功。我还尝试了pyinstaller的所有不同标志,例如--onefile
和--onedir
。我还尝试了Stack Overflow上的建议,使用pyinstaller的开发版本,但这并没有解决问题。非常感谢您提前的帮助!
英文:
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!
答案1
得分: 2
在经过了很多搜索后,最终导致我找到答案的关键术语是 Segmentation fault: 11
。一旦找到了这个,对我起作用的修复方法来自以下帖子(https://github.com/pyinstaller/pyinstaller/issues/7789):
pip uninstall pyinstaller
PYINSTALLER_COMPILE_BOOTLOADER=1 pip install git+https://github.com/pyinstaller/pyinstaller.git@develop
我希望这对其他遇到相同问题的人有所帮助!
英文:
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!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论