使用.app由py2app

时间:2016-01-20 21:59:21

标签: macos python-3.x qt5 pyqt5 py2app

TL / DR:与py2app捆绑的python应用程序一直在崩溃。

我用 pyqt5 编写了 python3.5 应用。它与python3 foo.py完美配合,即使我在别名模式下用 py2app 制作应用程序也是如此。

Btw python,pyqt ...已经安装了 MacPort 。 python35(来自MacPort)是一个活跃的。我在Contents / Resources中创建了一个空的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

我有点迷茫,知道为什么捆绑的应用程序不起作用? 谢谢:))

2 个答案:

答案 0 :(得分:0)

当我为我的独立应用程序下载并导入wx时,我遇到了类似的问题。

捆绑之前,

•PyQt5包必须位于应用程序的根目录中。

•setup.py必须包含以下行:package ='PyQt5'

答案 1 :(得分:0)

我遇到了同样的问题,经过几个小时没有找到解决方案切换到PyInstaller。我写了一些关于我的经历以及为什么我最终选择了PyInstaller而不是blog post中的其他替代方案。