In[1]:def fun1(a)def fun2(b)# I want to set a breakpoint for the following line #return do_some_thing_about(b)return fun2(a)In[2]:import multiprocessing as mp
pool=mp.Pool(processes=2)
results=pool.map(fun1,1.0)
pool.close()
pool.join
As I know, %debug magic can do debug within one cell.
However, I have function calls across multiple cells.
For example,
In[1]: def fun1(a)
def fun2(b)
# I want to set a breakpoint for the following line #
return do_some_thing_about(b)
return fun2(a)
In[2]: import multiprocessing as mp
pool=mp.Pool(processes=2)
results=pool.map(fun1, 1.0)
pool.close()
pool.join
What I tried:
I tried to set %debug in the first line of cell-1. But it enter into debug mode immediately, even before executing cell-2.
I tried to add %debug in the line right before the code return do_some_thing_about(b). But then the code runs forever, never stops.
What is the right way to set a break point within the ipython notebook?
The %pdb magic command is good to use as well. Just say %pdb on and subsequently the pdb debugger will run on all exceptions, no matter how deep in the call stack. Very handy.
If you have a particular line that you want to debug, just raise an exception there (often you already are!) or use the %debug magic command that other folks have been suggesting.
I just discovered PixieDebugger. Even thought I have not yet had the time to test it, it really seems the most similar way to debug the way we’re used in ipython with ipdb
A native debugger is being made available as an extension to JupyterLab. Released a few weeks ago, this can be installed by getting the relevant extension, as well as xeus-python kernel (which notably comes without the magics well-known to ipykernel users):