LinuxCommandLibrary

pudb

TLDR

Debug Python script

$ pudb [script.py]
copy
Debug with arguments
$ pudb [script.py] [arg1] [arg2]
copy
Start at breakpoint
$ python -m pudb [script.py]
copy
Post-mortem debugging
$ pudb --post-mortem [script.py]
copy

SYNOPSIS

pudb [options] script [args]

DESCRIPTION

pudb is a full-screen, console-based visual debugger for Python. It provides a TUI with code view, variable inspector, stack trace, and breakpoints.

PARAMETERS

--pre-run command

Run command before script.
--post-mortem
Debug after exception.
--steal-output
Capture stdout/stderr.
-m module
Run module.

EXAMPLES

$ # Debug script
pudb myscript.py

# With arguments
pudb myscript.py --config=test

# Run as module
python -m pudb myscript.py

# Post-mortem on crash
pudb --post-mortem crashing_script.py
copy

IN-CODE BREAKPOINT

$ import pudb; pudb.set_trace()

# Or Python 3.7+
breakpoint()  # with PYTHONBREAKPOINT=pudb.set_trace
copy

KEY BINDINGS

$ n     - Next line
s     - Step into
c     - Continue
b     - Set breakpoint
q     - Quit
?     - Help
Ctrl+p - Preferences
copy

CAVEATS

Terminal must support curses. May conflict with some terminal settings. Python-specific.

HISTORY

pudb was created by Andreas Klöckner as a visual alternative to pdb, inspired by Borland's Turbo Debugger.

SEE ALSO

pdb(1), ipdb(1), gdb(1), python(1)

Copied to clipboard