Spyder + Python 3.5 - how to debug kernel died, restarting?

梦想的初衷 提交于 2019-12-04 16:12:40
Michele Ancis

This issue is tracked here

You can learn all the details there, but in a nutshell when running from inside spyder - which itself is a QApplication, the main loop should read:

if __name__ == '__main__':
import sys
from PyQt5 import QtWidgets
fig1 = Figure()
if not QtWidgets.QApplication.instance():
    app = QtWidgets.QApplication(sys.argv)
else:
    app = QtWidgets.QApplication.instance() 
main = Main()
main.addmpl(fig1)
main.show()
sys.exit(app.exec_())

The if/then check on the existence of a QApplication avoids a segmentation fault which happens if one tries to launch multiple instances at one time, as explained here

I had a similar problem and found that my application only worked when the graphics settings inside Spyder are set to inline. This can be done at Tools -> Preferences -> IPython console -> Graphics, now change the Backends to inline.

Hope this helps.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!