Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

使用Qt写了个窗口,运行报错,无法正常运行python程序,获得的报错信息如下:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

经过仔细查看发现是在使用Qt模块导入了Qt4和Qt5两个模块(存在重合的部分),部分代码如下:


//Qt5
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QFont, QBrush
from PyQt5.QtWidgets import QTableWidget

from PyQt4 import Qt        //QT4



class Ui_TabWidget(object):



    def setupUi(self,TabWidget):
        TabWidget.setObjectName("TabWidget")
        TabWidget.resize(962, 618)
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")
        self.lineEdit = QtWidgets.QLineEdit(self.tab)
        self.lineEdit.setGeometry(QtCore.QRect(10, 20, 291, 31))
        self.lineEdit.setObjectName("lineEdit")
        self.label = QtWidgets.QLabel(self.tab)
        self.label.setGeometry(QtCore.QRect(310, 30, 54, 21))
        self.label.setObjectName("label")
        self.fontComboBox = QtWidgets.QFontComboBox(self.tab)
        self.fontComboBox.setGeometry(QtCore.QRect(350, 20, 161, 31))
        self.fontComboBox.setObjectName("fontComboBox")
        self.pushButton = QtWidgets.QPushButton(self.tab)

        ......

我尝试着去除Qt4和Qt5重合导入的模块,运行发现可以成功,自以为这就是失败的原因了,为了放心我又单独测试了一下导入Qt4,代码如下:

# !/usr/bin/env python
# -*- encoding:utf-8 -*-

import sys
from PyQt4 import QtCore, QtGui, QtWidgets

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    w = QtWidgets.QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('helloworld')
    w.show()
    sys.exit(app.exec_())

结果运行如下:

/usr/bin/python2.7 ~/helloworld

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

如此可以发现,不是由于重复导入模块而导致运行失败的,可以确认是由于Qt4模块自身出现了异常,猜测可能是由于sip导致Qt4模块的异常,然后发现我并没有PyQt4_gpl_x11,为了验证,我重新安装了PyQt4来验证,Ubuntu中安装配置过程如下:

1)安装sip
地址:http://www.riverbankcomputing.co.uk/software/sip/download

 cd sip-4.19.3/
 sudo python configure.py
 sudo make install

2)安装Qt4的依赖

sudo apt-get install qt4-dev-tools qt4-doc qt4-qtconfig qt4-demos qt4-designer
sudo apt-get install libqwt5-qt4 libqwt5-qt4-dev  

3)安装PyQt4

cd PyQt4_gpl_x11-4.12.1
sudo python configure.py  
sudo make  
sudo make install

重新运行,成功运行!!!

enjoytoday,enjoycoding

posted @ 2017-10-21 22:58  amiko  阅读(9372)  评论(0编辑  收藏  举报