[英]Segmentation fault (core dumped) in pyqt5
我試圖使QWebEnginePage可重啟的pyqt5應用程序。 但是出現了段錯誤。 這是代碼示例:
import sys
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import qApp
#from PyQt5.QtWebEngineWidgets import QWebEnginePage
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QMainWindow
from PyQt5.QtWebEngineWidgets import QWebEngineView
class MainWindow(QMainWindow):
EXIT_CODE_REBOOT = -123
def __init__(self,parent=None):
QMainWindow.__init__(self, parent)
self.timer = QTimer()
self.timer.timeout.connect(self.restart)
self.timer.start(3 * 1000)
self.qwe = QWebEngineView()
#self.qp = QWebEnginePage() # uncomment this will cause Segmentation fault (core dumped)
def restart(self):
print('restart')
qApp.exit(MainWindow.EXIT_CODE_REBOOT)
if __name__=="__main__":
currentExitCode = MainWindow.EXIT_CODE_REBOOT
while currentExitCode == MainWindow.EXIT_CODE_REBOOT:
print('next..')
a = QApplication(sys.argv)
w = MainWindow()
w.show()
currentExitCode = a.exec_()
a = None
有了這個評論-它工作正常。 但是,如果刪除注釋,則會顯示“分段錯誤(核心已轉儲)”。
你能給我個建議嗎?
轉載於PyQt 5.9.3和Ubuntu 14.04
使用Anaconda PyQt5時出現相同的錯誤
我通過安裝PyQt5
conda install -c anaconda pyqt
錯誤結果:
>>> from PyQt5 import *
>>> from PyQt5.QtGui import *
Segmentation fault (core dumped)
解決方法:
pip install PyQt5
結果:
>>> from PyQt5 import *
>>> from PyQt5.QtGui import *
>>>
希望它能起作用!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.