我正在尝试在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