Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run Python script twice without restarting Spyder

Tags:

python

spyder

I have installed WinPython with Python 3.3.3 and the Spyder IDE.

I have a problem with running files twice. The first time I run a file (using F5), there is no problem. The second time, Python or Spyder stucks. I can only stop it using Ctrl+C.

Each time, I want to run my file, I have to kill the current process in Spyder (using the exclamation mark in the orange triangle in the lower right corner), and afterwards restart the session using the green triangle, a button that appears next to the 'kill' button after clicking that 'kill' button.

Has anyone had de same problems, and how to solve this?

like image 376
vincentv Avatar asked Oct 24 '25 21:10

vincentv


1 Answers

There are many options for running a script in spyder. Try pressing F6 on your script to have a look at them.

Specifically, I get the same behavior if I run a blocking script "in the current interpreter" instead of "in a new interpreter". A single plt.show() can block a script from returning, for example.

If you can, I think that the best way to run a script in spyder is to run in a new interpreter, because this you're sure that you don't use any leftover variable from a previous run. And if the last run didn't terminate and you try to rerun it, spyder will ask you if you want to kill the last one before running it again.

like image 162
J. Martinot-Lagarde Avatar answered Oct 27 '25 12:10

J. Martinot-Lagarde