I have a strange error in my project that uses PySide for its Qt GUI, and in response I try to test a simpler code that sets up the environment.
Here is the code that I am testing: https://stackoverflow.com/a/165343/
When I run this from my shell ( python test.py
), it works fine. However, when I run this 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 this 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 this code work when launched from my shell, but not from Spyder?
Update: Mata replied that the problem is due to Spyder using Qt, which makes sense. At the moment, I installed execution in Spyder using the option "Run in an external system terminal", which does not cause errors, but also does not allow debugging. Does Spyder have any built-in workarounds?
source share