Join GitHub today
Seg Fault 11 when calling PySide using "run" command #1124
I am using iPython 0.11 to call a GUI about box written using PySide. Calling the GUI from inside iPython via
from qutip import * #my package
gives the correct result, i.e. opens the about window. However, running the exact same commands listed above inside a script file via
results in seg fault 11. Curiously, running
In: from qutip import *
In: run script.py
works just fine.
I am running iPython version 0.11 with Python 2.7.2, both installed using MacPorts, on Mac OSX 10.7.2. The current PySide version is 1.0.9. The relevant portion of the crash report generated is given below.
Process: Python 
Date/Time: 2011-12-08 16:20:04.623 +0900
Interval Since Last Report: 1676458 sec
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
VM Regions Near 0:
Application Specific Information:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
I'm not an expert on how the
look at #1001, and maybe some other issues , you can try
Does it make sens ? (If anyone who understand this better than me can confirm or correct...)
Thank you for the quick reply. Sadly your recommendations did not alleviate the problem. I guess a little more care is needed when running GUI scripts than I thought. Also since I didn't attach a code snippet earlier, the code below will generate the mentioned problem.
app = QtGui.QApplication(sys.argv)
I did not have segfault on master dev (but on mac), but it freeze when I click your button, not the close one in the menubar.
Still QApplication seem to be a singleton and I can't re-run it later...
I didin't know about
Thanks for the tip! Using app.quit never caused any problems in the past, at least on the Mac and Linux, but I think you are right. I am a physicist, so frankly I am surprised I could even get a window to popup in the first place!
On Dec 8, 2011, at 6:51 PM, Bussonnier Matthias wrote:
I'm a physicist too, and I don't think you'll find you'll find many people on this project whicht are not scientist before beeing programmers.
Is it working better now, or do you still have the issues ?
Just tried the dev version and it works!
You cannot run the window twice because the Qapplication is already running. I use this before executing the window to check if an instance is already running:
app=QtGui.QApplication.instance() # checks if QApplication already exists
then you can just call the window as usual:
On Dec 8, 2011, at 8:36 PM, Thomas wrote:
I tried looking into that very question about six months or so ago when I first wrote the GUI codes. However, I could not find a way to actually quit the Qapplication and then launch a new one. Although for what I am doing, this does not cause any issues.
On Dec 8, 2011, at 9:08 PM, Bussonnier Matthias wrote:
@takluyver was right, it does work with PyQt4, not PySide, even in plain python shell
example from link :
from PyQt4 import QtCore, QtGui #replace by PySide, it failed import sys app = QtGui.QApplication(sys.argv) window = QtGui.QWidget() window.show() app.exec_() del app # force garbage collection of the first QApplication app = QtGui.QApplication(sys.argv) window = QtGui.QWidget() window.show() app.exec_()
I'll try to report the bug upstream, unless one of you have already an account, and want to do it...
Ah good find. We try to support both pyside and pyqt4 for ourGUI's and it seems that having both of them kill the app in the same way is the proper thing to do. However, it is getting late here in Japan so go ahead and submit a report if you have time. Otherwise, I can get around to doing it tomorrow morning.
On Dec 8, 2011, at 9:38 PM, Bussonnier Matthias wrote: