To debug codes in a jupyter notebook:
-
Add
from IPython.core.debugger import set_trace
into the script; -
Add
set_trace()
as the breakpoint; -
Run this cell.
Note:
When the breakpoint is in the body of a function, running the cell will not invoke ipdb, but call the function will invoke ipdb.
After the debugging is done, remove set_trace()
.
And rerun the script with menu item Kernel > Restart & Run All.