Debugging IPython/Jupyter Notebook Using Pdb

Viewed 753

Due to limited access, I cannot use ipdb to debug my jupyter notebook codes, so I am using IPython.core.debugger.Pdb as debugger. The debug prompt shows ipdb> so I figure it is the same as ipdb in the background.

Below is my simple code in a notebook cell:

from IPython.core.debugger import Pdb
Pdb().set_trace()
j = 0
for i in range(10):
    j += i

The debugger at first shows ----> 1 Pdb().set_trace(), then I click n to go to the next line. Now the debugger goes into 'interactiveshell.py' and shows the following information:

   IPython/core/interactiveshell.py(2884)run_code()
   2882             finally:
   2883                 # Reset our crash handler in place
-> 2884                 sys.excepthook = old_excepthook
   2885         except SystemExit as e:
   2886             if result is not None:

The debugger does not return to my code after clicking r. How can I make the debugger go to the code I wrote instead of some system call?

0 Answers
Related