How to use
Last updated
Last updated
%debug
The easiest way to debug a Jupyter notebook is to use the %debug magic command. Whenever you encounter an error or exception, just open a new notebook cell, type %debug and run the cell. This will open a command line where you can test your code and inspect all variables right up to the line that threw the error.
Type “n” and hit Enter to run the next line of code (The → arrow shows you the current position). Use “c” to continue until the next breakpoint. “q” quits the debugger and code execution.
iPython debugger
Import it and use set_trace() anywhere in your notebook to create one or multiple breakpoints. When executing a cell, it will stop at the first breakpoint and open the command line for code inspection.
To invoke the PixieDebugger for a specific cell, simply add the %%pixie_debugger magic at the top of the cell and run it.
> Editor’s note: PixieDebugger currently only works with classic Jupyter Notebooks; JupyterLab is not yet supported.
Note: As a prerequisite, install PixieDust using the following pip command: pip install pixiedust
. You’ll also need to import it into its own cell: import pixiedust
.