TL/DR:我与py2app捆绑在一起的python应用程序不断崩溃。
我已经用pyqt5编写了一个python3.5应用程序。它与 python3 foo.py 完美配合,即使我在别名模式下使用 py2app 制作应用程序也是如此。
顺便说一句,蟒蛇,pyqt...已安装在 MacPort 中。python35(来自MacPort)是活跃的。我在内容/资源中创建了一个空的qt.conf。
但是,当py2app独立使用它时,foo.app 直接崩溃。做./dist/SoundRain.app/Contents/MacOS/SoundRain
回报[1] the-pid abort the-precedent-cmd
。
这里是报告(有用的部分):
System Integrity Protection: disabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
abort() called
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff957b10ae __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff855e4500 pthread_kill + 90
2 libsystem_c.dylib 0x00007fff97e1e37b abort + 129
3 org.qt-project.QtCore 0x00000001072e8c79 0x1072c2000 + 158841
4 org.qt-project.QtCore 0x00000001072ea667 QMessageLogger::fatal(char const*, ...) const + 231
5 org.qt-project.QtGui 0x0000000106e5b1b6 QGuiApplicationPrivate::createPlatformIntegration() + 6278
6 org.qt-project.QtGui 0x0000000106e5b1db QGuiApplicationPrivate::createEventDispatcher() + 27
7 org.qt-project.QtCore 0x00000001074a631c QCoreApplication::init() + 204
8 org.qt-project.QtCore 0x00000001074a6237 QCoreApplication::QCoreApplication(QCoreApplicationPrivate&) + 39
9 org.qt-project.QtGui 0x0000000106e5872e QGuiApplication::QGuiApplication(QGuiApplicationPrivate&) + 14
10 org.qt-project.QtWidgets 0x00000001068b17be QApplication::QApplication(int&, char**, int) + 206
11 QtWidgets.so 0x00000001063a33cf 0x10636d000 + 222159
12 sip.so 0x000000010953e7d4 0x10953c000 + 10196
13 org.python.python 0x0000000104963442 0x104911000 + 336962
14 org.python.python 0x000000010491b59d PyObject_Call + 97
15 org.python.python 0x00000001049b77db PyEval_EvalFrameEx + 21727
16 org.python.python 0x00000001049baf0c 0x104911000 + 696076
17 org.python.python 0x00000001049b2293 PyEval_EvalCode + 81
18 org.python.python 0x00000001049afdb9 0x104911000 + 650681
19 org.python.python 0x000000010495404d PyCFunction_Call + 273
20 org.python.python 0x00000001049b7a7f PyEval_EvalFrameEx + 22403
21 org.python.python 0x00000001049bb7cb 0x104911000 + 698315
22 org.python.python 0x00000001049b7914 PyEval_EvalFrameEx + 22040
23 org.python.python 0x00000001049baf0c 0x104911000 + 696076
24 org.python.python 0x00000001049b2293 PyEval_EvalCode + 81
25 org.python.python 0x00000001049d7e09 0x104911000 + 814601
26 org.python.python 0x00000001049d80ea PyRun_FileExFlags + 178
27 org.python.python 0x00000001049d773e PyRun_SimpleFileExFlags + 469
28 org.pythonmac.unspecified.SoundRain 0x000000010000275b 0x100000000 + 10075
29 org.pythonmac.unspecified.SoundRain 0x000000010000117a main + 650
30 org.pythonmac.unspecified.SoundRain 0x0000000100000be4 start + 52
Thread 1:
0 libsystem_kernel.dylib 0x00007fff957b178a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff855e158c _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff855df375 start_wqthread + 13
Thread 2:
0 libsystem_kernel.dylib 0x00007fff957b178a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff855e158c _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff855df375 start_wqthread + 13
Thread 3:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff957b20a2 kevent_qos + 10
1 libdispatch.dylib 0x00007fff831a611d _dispatch_mgr_invoke + 216
2 libdispatch.dylib 0x00007fff831a5d85 _dispatch_mgr_thread + 52
Thread 4:
0 libsystem_kernel.dylib 0x00007fff957b178a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff855e158c _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff855df375 start_wqthread + 13
Thread 5:
0 libsystem_kernel.dylib 0x00007fff957b178a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff855e158c _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff855df375 start_wqthread + 13
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x0000000000000006 rcx: 0x00007fff5fbfc8f8 rdx: 0x0000000000000000
rdi: 0x000000000000050f rsi: 0x0000000000000006 rbp: 0x00007fff5fbfc920 rsp: 0x00007fff5fbfc8f8
r8: 0x0000000000000040 r9: 0x00007fff767d11e0 r10: 0x0000000008000000 r11: 0x0000000000000206
r12: 0x000000010759a488 r13: 0x000000010a4b8370 r14: 0x00007fff72a6e000 r15: 0x000000010a4b5400
rip: 0x00007fff957b10ae rfl: 0x0000000000000206 cr2: 0x00007fff767cf038
Logical CPU: 0
Error Code: 0x02000148
Trap Number: 133
这是我在py2app上使用的 setup.py:
from setuptools import setup
APP = ['SoundRain.py']
DATA_FILES = [('.', ['resources/'])]
OPTIONS = {'argv_emulation': True,
"iconfile": "resources/soundrainlogo.icns",
"includes": ['sip', 'PyQt5._qt']}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
如果它有用,我在.py中所做的所有导入:
import sys
import os
import re
# PyQt5 imports
from PyQt5.QtWidgets import (QApplication, QWidget, QDesktopWidget,
QMainWindow, QAction, qApp,
QTextEdit, QHBoxLayout, QVBoxLayout,
QLabel, QLineEdit, QPushButton,
QFrame, QFileDialog, QMessageBox,
QInputDialog, QErrorMessage, QDialog,
QProgressBar)
from PyQt5.QtGui import (QPixmap, QIcon)
from PyQt5.QtCore import (QSettings, QObject, pyqtSignal,
pyqtSlot, Qt)
#import module for soundcloud, music handling, and file downloading
import soundcloud
import urllib
import httplib2
import requests
from mutagen.mp3 import MP3, EasyMP3
from mutagen.id3 import ID3, APIC
我有点迷茫,知道为什么捆绑的应用程序不起作用吗?谢谢:)
当我为我的独立应用程序下载和导入 wx 时,我遇到了类似的问题。
捆绑前,
• PyQt5 包必须位于应用程序的根目录中。
• setup.py 必须包含以下行:package='PyQt5'
我遇到了同样的问题,几个小时后没有找到解决方案切换到 PyInstaller。我在一篇博客文章中写了我的经历以及为什么我最终选择了 PyInstaller 而不是其他替代方案。