python - Python QApplication分段错误
问题描述
我正在尝试在 Ubuntu 机器上运行 pyt5,但即使是基本示例也失败了:
import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget
from PyQt5.QtCore import QSize
class HelloWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setMinimumSize(QSize(640, 480))
self.setWindowTitle("Hello world")
centralWidget = QWidget(self)
self.setCentralWidget(centralWidget)
gridLayout = QGridLayout(self)
centralWidget.setLayout(gridLayout)
title = QLabel("Hello World from PyQt", self)
title.setAlignment(QtCore.Qt.AlignCenter)
gridLayout.addWidget(title, 0, 0)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv) #<--crash after this line
mainWin = HelloWindow()
mainWin.show()
sys.exit( app.exec_())
尝试构建 QApplication 对象时,我得到:
进程以退出代码 139 结束(被信号 11 中断:SIGSEGV)
从 PyCharm(终端)外部运行相同的文件会产生:
分段错误(核心转储)
我在 Ubuntu 16.04.5 LTS 上使用 Python 3.6.5
解决方案
推荐阅读
- c# - UWP ComboBox IsEditable 无法正常工作
- java - 将转换器用于 DTO 时,休眠双向映射会导致循环
- java - 如何测试设置自定义存储库的 Gradle 插件?
- android - Android 上的跳转列表 - 如何实现按住 & 滑动
- c++builder - 编译时 Embarcadero C++ Builder 中的版本信息
- jquery - 处理 jQuery 中传递给 django 模板的对象列表以进行 Ajax 调用
- python - 你如何在manim中设置x和y轴标签的大小?
- sql - 带有postgreSQL函数的POSTMAN中的Json参数
- javascript - 谷歌翻译 - 弄乱 HTML 结构 - Javascript 中的 getAttribute 不起作用
- django - 如何在 django 应用程序中调用 collectstatic 例程?