Debugging a Jupyter Notebook cell#
This can be … problematic. There is a known issue with debugging Jupyter Notebooks in VS Code that makes working with it very frustrating from time to time, as described here: microsoft/vscode#150219
If you want to debug a Jupyter Notebook cell, click the arrow next to the cell and select “Debug Cell”:
This arrow sometimes disappear. If that happens, click in the toolbar: View - > Command Palette… and type “Developer: Reload Window”. This will reload the VS Code window and the arrow should appear again. Otherwise, you can click Ctrl
+ Shift
+ Alt
+ Enter
to start debugging a specific cell.
If this all works, you can debug notebooks in the same way as Python files, with breakpoints, stepping, inspecting variables, etc.
def compute_ratio(a, b):
return a / b # Put a breakpoint here, b can be 0
values = [1, 2, 3, 0, 4]
total = 0
for v in values:
# Set a conditional breakpoint here with expression: v == 0
total += compute_ratio(10, v)
total