0

this question is related to the code also shown here

An even more down-to-the-point code could be this:

import sys
import os
from PyQt4 import QtGui


class Window(QtGui.QDialog):

    def __init__(self, parent=None):
        super(Window, self).__init__(parent)

        # Just some extra button to mess around
        self.button= QtGui.QPushButton('Push Me')

        # set the layout
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.button)
        self.setLayout(layout)


if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)

    main = Window()
    main.show()

    sys.exit(app.exec_())

When I run this, a very silly one-button window appears, which does nothing :-) Still, when I close it, I get the following complaint from the IPython console:

An exception has occurred, use %tb to see the full traceback.

To exit: use 'exit', 'quit', or Ctrl-D.
An exception has occurred, use %tb to see the full traceback.

SystemExit: 0


In [3]: %tb
Traceback (most recent call last):

  File "<ipython-input-2-0a8f6cad0df5>", line 1, in <module>
    runfile('C:/Users/my_username/AppData/Local/Continuum/Anaconda3/Lib/site-packages/PyQt4/SE2.py', wdir='C:/Users/mtk10531/AppData/Local/Continuum/Anaconda3/Lib/site-packages/PyQt4')

  File "C:\Users\my_username\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 682, in runfile
    execfile(filename, namespace)

  File "C:\Users\my_username\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 85, in execfile
    exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)

  File "C:/Users/my_username/AppData/Local/Continuum/Anaconda3/Lib/site-packages/PyQt4/SE2.py", line 39, in <module>
    sys.exit(app.exec_())

SystemExit: 0

Then, running again produces the following:

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

I found other posts complaining about similar things, here and here

I have tried to implement what I understood (not much) from the answers, namely:

  • to pass the name of my script to QApplication: app = QtGui.QApplication(['my_file.py']) however this had no effect

  • to strip the app = QtGui.QApplication(['my_file.py']) from my main(), but in this case the Kernel just dies before doing anything else...

Any hint?

Cheers, Michele

P.S. - Just looking at the wavy pattern of \ and / in the traceback makes me sick!

Community
  • 1
  • 1
Michele Ancis
  • 1,265
  • 4
  • 16
  • 29
  • Here's a blog post that might be useful: [Making PyQt4, PySide and IPython work together](http://cyrille.rossant.net/making-pyqt4-pyside-and-ipython-work-together/) – Mel Jul 27 '15 at 12:04
  • @tmoreau thanks for the link, however it is generating more work than I predicted :-) It is somewhat old - 2012 - and the config file he refers to `ipython_config.py` is now several files. Also the structure looks different. I guess I'll just have to get the whole framework straight, which will take its time. – Michele Ancis Jul 27 '15 at 13:10

0 Answers0