打包 python .app 文件崩溃,但打包 python .sh 文件工作正常
Packaged python .app file crashing, but packaged python .sh file working fine
我在 OS X Yosemite.
上使用 Python 3.4.3、Pyqt4 和其他一些额外功能(Poppler 也在其中)制作了一个应用程序
我正在使用 cx_freeze 生成一个可用的 .app 文件,并最终生成一个可用的 msi 文件。在使用 "python3 setup.py build" 中的构建命令构建应用程序后,我一直在测试该应用程序是否正常工作。这一切工作正常,没有意外崩溃。
继续使用 "python3 setup.py bdist_dmg" 对其进行打包。打开 dmg file/app 文件,它们立即崩溃并给出此错误:
Process: main [1098]
Path: /Users/USER/*/FYP-0.1.app/Contents/MacOS/main
Identifier: main
Version: 0
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: main [1098]
User ID: 501
Date/Time: 2015-05-12 02:18:16.867 +0100
OS Version: Mac OS X 10.10.3 (14D131)
Report Version: 11
Anonymous UUID: 8A613A61-D35F-9A4C-8E97-57069A95BF20
Time Awake Since Boot: 1300 seconds
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
VM Regions Near 0:
-->
__TEXT 0000000103135000-0000000103138000 [ 12K] r- x/rwx SM=COW /Users/USER/*/FYP-0.1.app/Contents/MacOS/main
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 QtGui 0x000000010ecf126b QApplication::setActiveWindow(QWidget*) + 315
1 QtGui 0x000000010ec90b7d onApplicationWindowChangedActivation(QWidget*, bool) + 100
2 com.apple.CoreFoundation 0x00007fff8e99045c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
3 com.apple.CoreFoundation 0x00007fff8e880634 _CFXNotificationPost + 3140
4 com.apple.Foundation 0x00007fff94cd29d1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
5 com.apple.AppKit 0x00007fff9048dbd9 -[NSWindow becomeKeyWindow] + 1406
6 com.apple.AppKit 0x00007fff9048cf3e -[NSWindow _changeKeyAndMainLimitedOK:] + 795
7 com.apple.AppKit 0x00007fff9048cb36 -[NSWindow _makeKeyRegardlessOfVisibility] + 98
8 com.apple.AppKit 0x00007fff9048ca9e -[NSWindow makeKeyAndOrderFront:] + 27
9 QtGui 0x00000001045cfea7 QWidgetPrivate::show_sys() + 629
10 QtGui 0x000000010466c39c QWidgetPrivate::show_helper() + 432
11 QtGui 0x000000010466ccce QWidget::setVisible(bool) + 800
12 PyQt4.QtGui.so 0x0000000103f40634 sipQMainWindow::setVisible(bool) + 100
13 PyQt4.QtGui.so 0x00000001040f7ed9 meth_QWidget_show(_object*, _object*) + 105
14 Python 0x0000000103315ad5 PyEval_EvalFrameEx + 22129
15 Python 0x0000000103318f12 fast_function + 203
16 Python 0x0000000103315964 PyEval_EvalFrameEx + 21760
17 Python 0x00000001033102ad PyEval_EvalCodeEx + 1622
18 Python 0x000000010329e7ab function_call + 372
19 Python 0x000000010327e576 PyObject_Call + 103
20 Python 0x000000010328fca8 method_call + 136
21 Python 0x000000010327e576 PyObject_Call + 103
22 Python 0x00000001032c45b2 slot_tp_init + 57
23 Python 0x00000001032c1b48 type_call + 172
24 Python 0x000000010327e576 PyObject_Call + 103
25 Python 0x000000010331582a PyEval_EvalFrameEx + 21446
26 Python 0x00000001033102ad PyEval_EvalCodeEx + 1622
27 Python 0x000000010330fc51 PyEval_EvalCode + 63
28 Python 0x000000010330d6e3 builtin_exec + 536
29 Python 0x0000000103315ad5 PyEval_EvalFrameEx + 22129
30 Python 0x00000001033102ad PyEval_EvalCodeEx + 1622
31 Python 0x000000010330fc51 PyEval_EvalCode + 63
32 main 0x0000000103136cc5 main + 1957
33 libdyld.dylib 0x00007fff986995c9 start + 1
Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff91651232 kevent64 + 10
1 libdispatch.dylib 0x00007fff96fd0a6a _dispatch_mgr_thread + 52
Thread 2:
0 libsystem_kernel.dylib 0x00007fff9165094a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff92c4e40d start_wqthread + 13
Thread 3:
0 libsystem_kernel.dylib 0x00007fff9165094a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff92c4e40d start_wqthread + 13
Thread 4:
0 libsystem_kernel.dylib 0x00007fff9165094a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff92c4e40d start_wqthread + 13
Thread 5:
0 libsystem_kernel.dylib 0x00007fff9165094a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff92c4e40d start_wqthread + 13
Thread 6:
0 libsystem_kernel.dylib 0x00007fff9165094a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff92c4e40d start_wqthread + 13
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00007fbe8322a670 rcx: 0x00007fbe8326d0a0 rdx: 0x0000000000000002
rdi: 0x00007fbe8322a670 rsi: 0x0000000000000001 rbp: 0x00007fff5cac8ea0 rsp: 0x00007fff5cac8df0
r8: 0x0000000000000000 r9: 0x00007fbe830f90a0 r10: 0x0000000000000011 r11: 0x00007fff7bbdc190
r12: 0x00007fbe8322a670 r13: 0x00000000000f42cd r14: 0x00007fbe83296370 r15: 0x000000010f578228
rip: 0x000000010ecf126b rfl: 0x0000000000010202 cr2: 0x0000000000000000
Logical CPU: 0
Error Code: 0x00000004
Trap Number: 14
还有更多负载,但我不确定有多少是相关的。这是我的 setup.py 文件:
from cx_Freeze import setup, Executable
import sys
import os
base = None
if sys.platform == "win32":
base = "Win32GUI"
zips = ["implementation/primaries/GUI/designer_files",
"implementation/primaries/GUI/themes", "implementation/primaries/GUI/images",
"implementation/primaries/scripts"]
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"],
"include_files":zips}
setup(
name='FYP',
version='0.1',
packages=['implementation', 'implementation.primaries', 'implementation.primaries.GUI', 'implementation.primaries.scripts',
'implementation.primaries.GUI.pyqt_plugins', 'implementation.primaries.Drawing', 'implementation.primaries.Drawing.classes',
'implementation.primaries.Drawing.classes.tree_cls', 'implementation.primaries.ExtractMetadata',
'implementation.primaries.ExtractMetadata.classes', 'implementation.primaries.ImportOnlineDBs','implementation.primaries.ImportOnlineDBs.classes'],
description='MuseLib',
options = {"build_exe": build_exe_options},
executables = [Executable("implementation/main.py", base=base)]
)
不确定是什么问题,我看到其他一些人也有类似的问题,但他们似乎是在旧版本的 Python 或旧版本的 OS X 上,以及修复没有解决我的问题。任何关于如何进行的建议都将不胜感激。
看起来您可能缺少 QtGui dll 文件。我没有使用 cx_freeze 在 OS X 上打包,但通常你必须将 (QtCore, QtGui) dll 放入工作目录。您是否在设置中使用 QtGui 尝试过其他示例?
找到一个更好的调试方法:右键单击应用程序文件,"view package contents",MacOS > select 与 setup.py 中给出的文件同名的可执行文件(对我来说这是主要的)。
然后我得到错误:
QWidget: Must construct a QApplication before a QPaintDevice
我通过初始化我的应用程序对象解决了这个问题,然后初始化我的主要 window 对象,然后显示主要 window,然后调用设置 window 的加载方法.我最初是在构造函数中做那部分,由于某种原因会出现问题。
我现在遇到 opening/closing windows 的问题并在关闭时打开其他问题,但这可能是另一个问题或谷歌搜索会话的最佳选择。
我在 OS X Yosemite.
上使用 Python 3.4.3、Pyqt4 和其他一些额外功能(Poppler 也在其中)制作了一个应用程序我正在使用 cx_freeze 生成一个可用的 .app 文件,并最终生成一个可用的 msi 文件。在使用 "python3 setup.py build" 中的构建命令构建应用程序后,我一直在测试该应用程序是否正常工作。这一切工作正常,没有意外崩溃。 继续使用 "python3 setup.py bdist_dmg" 对其进行打包。打开 dmg file/app 文件,它们立即崩溃并给出此错误:
Process: main [1098]
Path: /Users/USER/*/FYP-0.1.app/Contents/MacOS/main
Identifier: main
Version: 0
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: main [1098]
User ID: 501
Date/Time: 2015-05-12 02:18:16.867 +0100
OS Version: Mac OS X 10.10.3 (14D131)
Report Version: 11
Anonymous UUID: 8A613A61-D35F-9A4C-8E97-57069A95BF20
Time Awake Since Boot: 1300 seconds
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
VM Regions Near 0:
-->
__TEXT 0000000103135000-0000000103138000 [ 12K] r- x/rwx SM=COW /Users/USER/*/FYP-0.1.app/Contents/MacOS/main
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 QtGui 0x000000010ecf126b QApplication::setActiveWindow(QWidget*) + 315
1 QtGui 0x000000010ec90b7d onApplicationWindowChangedActivation(QWidget*, bool) + 100
2 com.apple.CoreFoundation 0x00007fff8e99045c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
3 com.apple.CoreFoundation 0x00007fff8e880634 _CFXNotificationPost + 3140
4 com.apple.Foundation 0x00007fff94cd29d1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
5 com.apple.AppKit 0x00007fff9048dbd9 -[NSWindow becomeKeyWindow] + 1406
6 com.apple.AppKit 0x00007fff9048cf3e -[NSWindow _changeKeyAndMainLimitedOK:] + 795
7 com.apple.AppKit 0x00007fff9048cb36 -[NSWindow _makeKeyRegardlessOfVisibility] + 98
8 com.apple.AppKit 0x00007fff9048ca9e -[NSWindow makeKeyAndOrderFront:] + 27
9 QtGui 0x00000001045cfea7 QWidgetPrivate::show_sys() + 629
10 QtGui 0x000000010466c39c QWidgetPrivate::show_helper() + 432
11 QtGui 0x000000010466ccce QWidget::setVisible(bool) + 800
12 PyQt4.QtGui.so 0x0000000103f40634 sipQMainWindow::setVisible(bool) + 100
13 PyQt4.QtGui.so 0x00000001040f7ed9 meth_QWidget_show(_object*, _object*) + 105
14 Python 0x0000000103315ad5 PyEval_EvalFrameEx + 22129
15 Python 0x0000000103318f12 fast_function + 203
16 Python 0x0000000103315964 PyEval_EvalFrameEx + 21760
17 Python 0x00000001033102ad PyEval_EvalCodeEx + 1622
18 Python 0x000000010329e7ab function_call + 372
19 Python 0x000000010327e576 PyObject_Call + 103
20 Python 0x000000010328fca8 method_call + 136
21 Python 0x000000010327e576 PyObject_Call + 103
22 Python 0x00000001032c45b2 slot_tp_init + 57
23 Python 0x00000001032c1b48 type_call + 172
24 Python 0x000000010327e576 PyObject_Call + 103
25 Python 0x000000010331582a PyEval_EvalFrameEx + 21446
26 Python 0x00000001033102ad PyEval_EvalCodeEx + 1622
27 Python 0x000000010330fc51 PyEval_EvalCode + 63
28 Python 0x000000010330d6e3 builtin_exec + 536
29 Python 0x0000000103315ad5 PyEval_EvalFrameEx + 22129
30 Python 0x00000001033102ad PyEval_EvalCodeEx + 1622
31 Python 0x000000010330fc51 PyEval_EvalCode + 63
32 main 0x0000000103136cc5 main + 1957
33 libdyld.dylib 0x00007fff986995c9 start + 1
Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff91651232 kevent64 + 10
1 libdispatch.dylib 0x00007fff96fd0a6a _dispatch_mgr_thread + 52
Thread 2:
0 libsystem_kernel.dylib 0x00007fff9165094a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff92c4e40d start_wqthread + 13
Thread 3:
0 libsystem_kernel.dylib 0x00007fff9165094a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff92c4e40d start_wqthread + 13
Thread 4:
0 libsystem_kernel.dylib 0x00007fff9165094a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff92c4e40d start_wqthread + 13
Thread 5:
0 libsystem_kernel.dylib 0x00007fff9165094a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff92c4e40d start_wqthread + 13
Thread 6:
0 libsystem_kernel.dylib 0x00007fff9165094a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff92c4e40d start_wqthread + 13
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00007fbe8322a670 rcx: 0x00007fbe8326d0a0 rdx: 0x0000000000000002
rdi: 0x00007fbe8322a670 rsi: 0x0000000000000001 rbp: 0x00007fff5cac8ea0 rsp: 0x00007fff5cac8df0
r8: 0x0000000000000000 r9: 0x00007fbe830f90a0 r10: 0x0000000000000011 r11: 0x00007fff7bbdc190
r12: 0x00007fbe8322a670 r13: 0x00000000000f42cd r14: 0x00007fbe83296370 r15: 0x000000010f578228
rip: 0x000000010ecf126b rfl: 0x0000000000010202 cr2: 0x0000000000000000
Logical CPU: 0
Error Code: 0x00000004
Trap Number: 14
还有更多负载,但我不确定有多少是相关的。这是我的 setup.py 文件:
from cx_Freeze import setup, Executable
import sys
import os
base = None
if sys.platform == "win32":
base = "Win32GUI"
zips = ["implementation/primaries/GUI/designer_files",
"implementation/primaries/GUI/themes", "implementation/primaries/GUI/images",
"implementation/primaries/scripts"]
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"],
"include_files":zips}
setup(
name='FYP',
version='0.1',
packages=['implementation', 'implementation.primaries', 'implementation.primaries.GUI', 'implementation.primaries.scripts',
'implementation.primaries.GUI.pyqt_plugins', 'implementation.primaries.Drawing', 'implementation.primaries.Drawing.classes',
'implementation.primaries.Drawing.classes.tree_cls', 'implementation.primaries.ExtractMetadata',
'implementation.primaries.ExtractMetadata.classes', 'implementation.primaries.ImportOnlineDBs','implementation.primaries.ImportOnlineDBs.classes'],
description='MuseLib',
options = {"build_exe": build_exe_options},
executables = [Executable("implementation/main.py", base=base)]
)
不确定是什么问题,我看到其他一些人也有类似的问题,但他们似乎是在旧版本的 Python 或旧版本的 OS X 上,以及修复没有解决我的问题。任何关于如何进行的建议都将不胜感激。
看起来您可能缺少 QtGui dll 文件。我没有使用 cx_freeze 在 OS X 上打包,但通常你必须将 (QtCore, QtGui) dll 放入工作目录。您是否在设置中使用 QtGui 尝试过其他示例?
找到一个更好的调试方法:右键单击应用程序文件,"view package contents",MacOS > select 与 setup.py 中给出的文件同名的可执行文件(对我来说这是主要的)。
然后我得到错误:
QWidget: Must construct a QApplication before a QPaintDevice
我通过初始化我的应用程序对象解决了这个问题,然后初始化我的主要 window 对象,然后显示主要 window,然后调用设置 window 的加载方法.我最初是在构造函数中做那部分,由于某种原因会出现问题。 我现在遇到 opening/closing windows 的问题并在关闭时打开其他问题,但这可能是另一个问题或谷歌搜索会话的最佳选择。