Interactive Debugging with pdb
marimo fully supports Python’s built-in debugger (pdb), allowing you to set breakpoints, inspect variables, and step through code execution.Setting Breakpoints
Use thebreakpoint() function to pause execution and enter the debugger:
breakpoint(), marimo enters an interactive debugging session in your terminal where you can:
- Inspect variable values with
p variable_name - Step through code with
n(next) ors(step into) - Continue execution with
c - Quit the debugger with
q - See all commands with
help
The debugger blocks execution: While the debugger is active, you cannot execute other cells. Remember to continue (
c) or quit (q) the debugger to resume normal operation.Breakpoints from Stack Traces
When a cell raises an exception, marimo displays a detailed stack trace. You can add breakpoints directly from the error output:- Click the bug icon (🐛) in the stack trace
- marimo adds a
breakpoint()at that location - Re-run the cell to enter the debugger at the error point
Postmortem Debugging
When your code raises an exception, marimo offers postmortem debugging to inspect the program state at the point of failure. To use postmortem debugging:- Run a cell that raises an exception
- Click the “Launch debugger” button in the error output
- Inspect variables and stack frames at the point of the error
Error Messages and Inspection
marimo provides rich, detailed error messages to help you quickly identify issues.Stack Traces
When a cell throws an error, marimo displays:- Exception type and message: Clear description of what went wrong
- Full stack trace: Complete path through your code leading to the error
- Source code context: Lines of code surrounding each stack frame
- Variable values: Inspect local variables at each frame level
- Cell references: Direct links to the cells involved in the error
Variable Inspector
The variable explorer panel shows all variables in your notebook:- Open the Variables panel from the left sidebar
- Browse all defined variables and their values
- Expand complex objects to inspect their structure
- Click variables to see their full representation
Debugging Reactivity Issues
marimo’s reactive execution model can sometimes lead to unexpected behavior. Use these tools to debug reactivity:Dataflow Graph
Visualize cell dependencies to understand execution order:- Click the dependency graph icon in the notebook toolbar
- See which cells depend on each other
- Identify circular dependencies or missing connections
Common reactivity issues
Common reactivity issues
Stale cells: If cells aren’t updating when you expect:
- Check the dependency graph for broken connections
- Ensure cells reference variables correctly (not through side effects)
- Verify cells return the values they create
- Check which variables the cell references
- Look for global variable mutations
- Review the dependency graph for indirect connections
Execution Order
Unlike traditional notebooks, marimo executes cells based on dependencies, not position. To debug execution order:- Check the cell run order indicator (small number on each cell)
- Verify dependencies in the dataflow graph
- Ensure cells don’t depend on execution side effects
Debugging as Scripts
Since marimo notebooks are pure Python files, you can debug them using standard Python debugging tools.Running with pdb
Run your notebook as a script with the Python debugger:- Set breakpoints with
b line_numberorb function_name - Step through cell execution
- Inspect the full program state
Running with pytest
Debug test cells using pytest:--pdb flag.
marimo automatically detects and runs test functions in cells when
reactive_tests = true in your runtime configuration.AI-Powered Debugging
marimo integrates AI assistance to help debug errors and understand issues faster.Ask AI About Errors
When you encounter an error:- Open the AI chat panel from the left sidebar
- Reference errors using
@Errorsin your prompt - The AI receives full error context including stack traces and variable states

@Errors Why is this TypeError occurring?@Errors How can I fix this import error?@Errors Explain why these cells aren't updating
Best Practices for AI-Assisted Debugging
Provide context beyond the error
Provide context beyond the error
Help the AI understand your intent:Include:
- What you were trying to accomplish
- Recent changes you made
- Related cells that might be involved
Ask specific questions
Ask specific questions
Instead of generic requests, be specific:❌ “Why is this broken?”✅ “Why is this cell not re-running when I update the dataframe in the previous cell?”✅ “How can I fix this TypeError when calling process_data()?”✅ “What’s causing this performance issue in my groupby operation?”
Leverage marimo's debugging tools first
Leverage marimo's debugging tools first
- Use the dependency graph to understand cell relationships
- Check the variable explorer for unexpected values
- Review stack traces for error locations
- Then share these insights with the AI for targeted advice
Debugging Tools
marimo provides several built-in tools to aid debugging:Console Output Panel
View all print statements and console output:- Open the Console panel from the bottom toolbar
- See stdout/stderr from all cells
- Filter output by cell or search for specific messages
Cell Status Indicators
Each cell shows its execution status:- ✅ Green checkmark: Successfully executed
- ⚠️ Yellow warning: Cell is stale (needs re-run)
- ❌ Red X: Execution failed with an error
- ⏳ Spinner: Currently executing
Runtime Configuration
Adjust runtime behavior for easier debugging:pyproject.toml
Common Debugging Scenarios
Debugging import errors
Debugging import errors
Symptom: Module not found or import errorsSolutions:
- Check the Dependencies panel to see installed packages
- Verify the module is installed: Use the package manager panel
- Check
sys.pathfor Python path issues - Review
pythonpathsetting in runtime configuration
Debugging cell dependencies
Debugging cell dependencies
Symptom: Cells not updating when expectedSolutions:
- Open the dependency graph to visualize connections
- Ensure cells return values they create:
return variable - Check for hidden state or global mutations
- Verify variable names are consistent across cells
Debugging performance issues
Debugging performance issues
Symptom: Slow notebook executionSolutions:
- Use
%%timeor%%timeitto measure cell execution - Check the execution order - are cells running more than expected?
- Enable lazy execution to prevent automatic re-runs
- Profile with
cProfileor line_profiler
Debugging data issues
Debugging data issues
Symptom: Unexpected values or data transformationsSolutions:
- Use the variable explorer to inspect dataframe shapes and types
- Add assertions to validate assumptions:
- Use
mo.ui.table(df)to interactively explore data - Add temporary print statements to track data flow
Debugging Configuration
Diagnostics Settings
Enable rich diagnostics from language servers:pyproject.toml
Language Servers for Error Detection
Configure language servers to catch errors before runtime:pyproject.toml
Troubleshooting Tips
Related Documentation
- Reactivity Guide - Understanding marimo’s reactive execution
- Error Handling - Best practices for robust code
- AI Completion - AI-powered debugging assistance
- Testing - Writing and running tests in marimo