Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we get Spyder to pause execution after an error has occurred?

Tags:

python

spyder

I'm debugging a program, and I would like it if Spyder could pause execution at an error. I had read previously that this can be done without breakpoints by just running scripts in Debug mode, but that isn't working for me.

Eg, when I run the following script in Debug mode in Spyder, it just errors out at the index out of range exception without giving me any opportunity in ipdb to play with the variables.

import numpy as np   

A = np.random.randn(5)

A[7] = 8 #IndexError

More specifically, when I start debug, it starts me at the first line, then when I press Continue, execution proceeds all the way through line 3 without giving me a chance to inspect the workspace before execution exits.

Any thoughts?

Thanks.

like image 867
user49404 Avatar asked Nov 06 '22 17:11

user49404


1 Answers

I guess that if you launch your script under the "Run" > "Configuration per file" window and check "Directly enter debugging when errors appear" you get what you need. You should then run the script normally (not in debug mode).

like image 123
mdgm Avatar answered Nov 14 '22 03:11

mdgm