Reputation: 3
I have installed the latest anaconda version (1.9.7) which includes python 3.7.3, spyder 3.3.3, ipython 7.4.0, pyqt 5.9.2 and now I'm having problem running a code that was working fine with the previous anaconda installation (anaconda 1.7.0, python : 3.6.4, Ipython : 6.2.1 and spyder : 3.2.6). I have checked that spyder --> Tool--> preference --> Ipython console are the same with both installation.
Here the code :
import sys
from PyQt5 import QtWidgets
if __name__ == '__main__':
if not QtWidgets.QApplication.instance():
app = QtWidgets.QApplication(sys.argv)
else:
app = QtWidgets.QApplication.instance()
T = QtWidgets.QErrorMessage()
T.setWindowTitle('Error!')
T.showMessage('some message')
T.show()
app.exec()
So basically when I run the code (above) I can see that my GUI opens up. However when I close the GUI (using the X on the right side of the GUI) IPython console hangs and I have no choice to restart spyder (ctr C doesn't do anything in this case). I have found out that I can fix the issue by removing the line :'app.exec()'. However, most of the time I'm running my code from anaconda prompt so I don't want to remove 'app.exec()' from my code. This code was working fine with the previous installation with both anaconda prompt and spyder (so basically with and w/o using ipython).
I have tried Tools--> Ipython console --> Graphics--> Backend --> Automatic and it doesn't change anything. If I uncheck 'Activate support' (Tools--> Ipython console --> Graphics) it resolves the problem but I don't want to go to that direction because I found out that I won't be able to use matplotlib correctly (plots won't show up without plt.show() and this will blocks ipython) (with the previous installation 'Activate support' was checked). I can of course go back to the previous installation but I want to avoid that since I have other problems with the old installation (and I believe that the latest version should works fine). I know I can fix this problem temporary (removing app.exec() when I use spyder or uncheck 'Activate support') but I was wondering if I'm missing something or this is a problem related to the new ipython. Please let me know if you have any suggestion.
Upvotes: 0
Views: 489
Reputation: 34156
(Spyder maintainer here) You said
I have found out that I can fix the issue by removing the line :'app.exec()'.
So, if you want to run your code in and out of Spyder, you can enclose that line in the following if
block:
import os
if not os.environ.get('SPY_UMR_ENABLED'):
app.exec()
That would avoid to run it in Spyder because the SPY_UMR_ENABLED
environment variable is present in our consoles, but it's not present in the Anaconda prompt or the Jupyter notebook.
Upvotes: 1