LoginSignup
0
1

More than 5 years have passed since last update.

Spyderで2度めのPyQtが実行出来ない

Posted at

It seems the kernel died unexpectedly. Use 'Restart kernel' to continue using this console.

と出力され続ける。
新しいpython consoleを開かないと再実行できない。

検証環境

  • Python 2.7 (WinPython-32bit-2.7.10.3)
  • Spyder 3.0.0 (同梱)
  • PyQt4
  • Windows7
import sys
import PyQt4

app = PyQt4.QtGui.QApplication(sys.argv)
mw = PyQt4.QtGui.QMainWindow()
button = PyQt4.QtGui.QPushButton('Hello World')
mw.setCentralWidget(button)
mw.show()
app.exec_()

対処

import sys
import PyQt4

app = PyQt4.QtGui.QApplication(sys.argv)
mw = PyQt4.QtGui.QMainWindow()
button = PyQt4.QtGui.QPushButton('Hello World')
mw.setCentralWidget(button)
mw.show()
# 追加
app.aboutToQuit.connect(app.deleteLater)
app.exec_()

終了時に接続を開放するということかな?
参考ではインスタンスの使い回しを示唆するコードがあったが、現状これで動いているので様子見。

参考


0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1