0

In jupyter, when an error occurs, we can continuously debug the error with the command %debug. I want to know if there is the similar way in running python script (.py) in the shell.

I know that I can use pdb to make some break points, but I just want to know the way without such a pre-processing (because re-running the code until the error costs a lot of time).

Yanghoon
  • 572
  • 5
  • 18
  • 2
    `pdb` used post mortem seems like the preferred way in that case: https://stackoverflow.com/questions/18960242/is-it-possible-to-automatically-break-into-the-debugger-when-a-exception-is-thro/18962528 – MatsLindh May 18 '21 at 23:51

1 Answers1

0

In general, no: it depends on "the shell" that you are running. Jupyter launches with a lot of instrumentation in support of its debugger, assuming that you're using Jupyter because you want those capabilities at the ready.

I presume that you're using some UNIX shell (since you mention pdb); implicitly loading superfluous software is antithetical to the UNIX philosophy.

I think that what you'll need is one of the "after" debugger modes, although that will still leave you without information from just before the error point: those packages cannot do much to trace the history of problem variables.

Prune
  • 76,765
  • 14
  • 60
  • 81
  • Thanks for the answer. Can u give me some examples of 'those packages cannot do much to trace the history of problem variables' if u know some of them. – Yanghoon May 19 '21 at 00:00