环境:
Python 3.8
Pyqt5
Mac Catalina 10.15.6
我试图在Mac应用程序中编译我的python程序。打开应用程序时,我会收到以下错误消息:
(base) gb@MacBookGB % open dist/MyApplication.app
LSOpenURLsWithRole() failed with error -10810 for the file /Users/gb/myapp/dist/MyApplication.app.我检查了可以执行的文件:
ld -la dist/
drwxr-xr-x@ 4 gb staff 128 26 aoû 20:27 .
drwxr-xr-x@ 223 gb staff 7136 26 aoû 20:44 ..
-rw-r--r--@ 1 gb staff 6148 26 aoû 21:04 .DS_Store
drwxr-xr-x@ 3 gb staff 96 26 aoû 20:18 MyApplication.app
ld -la dist/MyApplication.app/Contents/Mac OS/
total 7016
drwxr-xr-x@ 4 gauthierbtz staff 128 26 aoû 20:18 .
drwxr-xr-x@ 7 gauthierbtz staff 224 26 aoû 20:18 ..
-rwxr-xr-x@ 1 gauthierbtz staff 30048 26 aoû 20:18 PhoneBot_small
-rwxr-xr-x@ 1 gauthierbtz staff 3557260 26 aoû 20:18 python所以我在网上到处寻找解决方案,但都没有用。据我所知,Qt5在编译时可能会引起问题,我搜索了一下,并找到了您的文章:https://doc.qt.io/qtforpython/deployment-pyinstaller.html
我决定编译本文中所示的python代码。
import sys
import random
from PySide2.QtWidgets import (QApplication, QLabel, QPushButton,
QVBoxLayout, QWidget)
from PySide2.QtCore import Slot, Qt
class MyWidget(QWidget):
def __init__(self):
QWidget.__init__(self)
self.hello = ["Hallo Welt", "你好,世界", "Hei maailma",
"Hola Mundo", "Привет мир"]
self.button = QPushButton("Click me!")
self.text = QLabel("Hello World")
self.text.setAlignment(Qt.AlignCenter)
self.layout = QVBoxLayout()
self.layout.addWidget(self.text)
self.layout.addWidget(self.button)
self.setLayout(self.layout)
# Connecting the signal
self.button.clicked.connect(self.magic)
@Slot()
def magic(self):
self.text.setText(random.choice(self.hello))
if __name__ == "__main__":
app = QApplication(sys.argv)
widget = MyWidget()
widget.resize(800, 600)
widget.show()
sys.exit(app.exec_())然后我运行命令:
pyinstaller --name="MyApplication" --windowed MyApp.py我也遇到了同样的问题:
LSOpenURLsWithRole() failed with error -10810 for the file /Users/gb/myapp/dist/MyApplication.app.我想知道是否有人已经面对这个问题并找到了解决办法?
发布于 2022-05-01 01:52:03
对于应用程序中可执行文件中的错误,-10810错误消息似乎是一个陷阱。例如,我有一个名为Hello.app的应用程序,在Hello.app/Content/MacOS内部是一个名为Hello的可执行脚本,有两行代码:
#!/bin/sh
osascript -e "display dialog \"Hello, world!\""当我发出命令时:
open Hello.app或者双击Finder中的文件夹图标。我看到了预期的对话框:

但是,当我介绍语法错误时:
osascript -e "display dialog "Hello, world!\""open命令在错误消息中失败:
LSOpenURLsWithRole() failed with error -10810 for the file /full/path/name/of/Hello.app要找到真正的错误消息,直接从命令行执行应用程序中的程序。在我的例子中,命令是:
Hello.app/Contents/MacOS/Hello信息更丰富的错误信息是:
./Hello: line 2: unexpected EOF while looking for matching `"'当然,我不知道你的程序中的实际错误是什么,但我希望这能帮助你找到它!
https://stackoverflow.com/questions/63604429
复制相似问题