python-3.x - 文件 /Users/gb/myapp/dist/MyApplication.app 的 LSOpenURLsWithRole() 失败,错误为 -10810
问题描述
环境:
蟒蛇 3.8
pyqt5
Mac OS X 卡特琳娜 10.15.6
我正在尝试在 Mac OS 应用程序中编译我的 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](link url)
我决定编译本文中显示的 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.
我想知道是否有人已经遇到过这个问题并找到了解决方案?
解决方案
推荐阅读
- python - 如何使用 Python 客户端正确验证 Kusto?
- r - 如何使用 tmap 在 R 中手动设置点的颜色
- css - 如何用卡片制作引导轮播
- c++ - “if constexpr(something false)”是否总是省略模板实例化
- python - 如何使用自定义名称从 h2o MOJO 下载中保存 jar 文件?
- scala - 文件合并逻辑:scala
- c++ - 如何制作文件中所有不同单词的字母顺序列表以及每个单词的使用次数?
- rust - 有没有办法制作一个包含自身向量的特征?
- mongodb - 连接到不同命名空间中的 Kubernetes mongo db
- jquery - 无限重复而不返回的图像滑块