PySide Qt script doesn't launch from Spyder but works from shell

Posted by Maxim Zaslavsky on Stack Overflow See other posts from Stack Overflow or by Maxim Zaslavsky
Published on 2012-05-22T19:58:41Z Indexed on 2013/06/29 4:21 UTC
Read the original article Hit count: 258

Filed under:
|
|
|
|

I have a weird bug in my project that uses PySide for its Qt GUI, and in response I'm trying to test with simpler code that sets up the environment.

Here is the code I am testing with: http://stackoverflow.com/a/6906552/130164

When I launch that from my shell (python test.py), it works perfectly. However, when I run that script in Spyder, I get the following error:

Traceback (most recent call last):
  File "/home/test/Desktop/test/test.py", line 31, in <module>
    app = QtGui.QApplication(sys.argv)
RuntimeError: A QApplication instance already exists.

If it helps, I also get the following warning:

/usr/lib/pymodules/python2.6/matplotlib/__init__.py:835: UserWarning:  This call to matplotlib.use() has no effect
because the the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

Why does that code work when launched from my shell but not from Spyder?


Update: Mata answered that the problem happens because Spyder uses Qt, which makes sense. For now, I've set up execution in Spyder using the "Execute in an external system terminal" option, which doesn't cause errors but doesn't allow debugging, either. Does Spyder have any built-in workarounds to this?

© Stack Overflow or respective owner

Related posts about python

Related posts about qt