Home > Net >  Is there any way to debug user-written modules if they are used in Jupyter notebook?
Is there any way to debug user-written modules if they are used in Jupyter notebook?

Time:01-11

I want to know, is there any way to debug user-written modules, if they are used in Jupyter notebook, using VSCode?

I want it to work so that if I create a breakpoint in my module and when I call some function from this module in Jupyter notebook, it will stop and allow me to see some useful data. Default VSCode debugger works this way only if breakpoint is set in the file that I run.

I tried to set breakpoints (like function or red dot on the left from the code) in module, but calling function with it from notebook doesn't trigger it.

CodePudding user response:

You can add import pdb; pdb.set_trace() from python pdb to add a breakpoint in your code.

CodePudding user response:

I got answer, that is OK to me. In VSCode I can export notebook as Python script enter image description here

and then I can write breakpoint() in necessary place in my module. If I run the exported Python script, then breakpoint activates and I can see all values. Anyway, thanks to everybody for help.

  • Related