I am trying to run through some pyqt5 tutorials in the ipython notebook, but have an issue where every second time I run a code block the kernal undergoes a forced restart. Here is the smallest code which causes the problem:
import sys
from PyQt5.QtWidgets import QApplication, QWidget
if __name__ == '__main__':
app = QApplication(sys.argv)
w = QWidget()
w.setWindowTitle('Simple')
w.show()
sys.exit(app.exec_())
I am running the Ipython3 notebook and python 3, as well as pyqt5, and using Ubuntu 14.04. It should be noted that this problem does not occur when running this same code via a script in terminal.
Some other unrelated questions have suggested that my problem could be due to sys.exit() messing with the instance of python(I hope that is the correct term) instead of just closing my pyqt application. This happens the first time I run the code, so that the second time it runs the kernel is forced to restart. Is this the problem? and if so how do I work around this?
If more info is required, please ask.