python - Debugging a PyQt application using PyDev+Eclipse -
i routinely use pydev in eclipse python development. however, i'm trying pyqt first time in same environment. works well, 1 exception. if program errors out anywhere within qt main event loop, including within own code, no error information output pydev console.
to demonstrate created following simple pyqt app:
import sys pyqt5 import uic pyqt5.qtwidgets import qapplication # test.ui contains single push button named pushbutton base, form = uic.loaduitype("../ui/test.ui") class mainwindow(base, form): def __init__(self, parent=none): super(base, self).__init__(parent) self.setupui(self) self.pushbutton.clicked.connect(self.button_pressed) def button_pressed(self): print('button pressed') print(invalid_variable) # intentional error pass if __name__ == '__main__': app = qapplication(sys.argv) app.setstyle("fusion") main_window = mainwindow() main_window.show() sys.exit(app.exec_())
if place intentional error such print(invalid_variable)
anywhere after if __name__ == '__main__':
, before app.exec_()
command, program terminates traceback , expected nameerror: name 'invalid_variable' not defined
. however, if press button in dialog using above code, button pressed
appears on console application terminates silently , no error information in console. other debugging operations, such breakpoints , expressions, work fine.
is expected behavior? if so, recommend facilitating debugging of pyqt apps in environment. if not, i'd appreciate insight need rectify problem.
- python version: python-3.4.3.amd64
- pydev version: pydev eclipse 4.3.0.201508182223
- pyqt version: pyqt5-5.5-gpl-py3.4-qt5.5.0-x64
update 2015-09-30:
when run test app directly python.exe, outputs error correctly stderr in both error scenarios. issue seem specific pydev environment. additionally created entirely fresh eclipse workspace python interpreter configured , ran test again on freshly created pydev project using same source code. results same.
this old question, thought i'd provide answer since shows on google searches problem.
the issue changes pyqt5.5+ handling of errors, including following code reenable stacktrace on crashes.
it took alot of random browsing on internet, found code needed work around problem, posted here reference else has same issue. obvious when found it. ;)
from pyqt5 import qtcore import traceback, sys if qtcore.qt_version >= 0x50501: def excepthook(type_, value, traceback_): traceback.print_exception(type_, value, traceback_) qtcore.qfatal('') sys.excepthook = excepthook
hope helps others.
Comments
Post a Comment