python-debugpy

Debug Python code with pdb breakpoints, post-mortem inspection, and debugpy remote attach.

Updated May 13, 2026
One-click install
npx skills add https://github.com/superfhp/lumi-agent-body --skill python-debugpy-superfhp
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: python-debugpy
Source: https://github.com/superfhp/lumi-agent-body/tree/main/skills/software-development/python-debugpy
Command: npx skills add https://github.com/superfhp/lumi-agent-body --skill python-debugpy-superfhp

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires debugpy, remote-pdb.

What problem does it solve? Python bugs in tests, long-running daemons, and subprocesses are hard to diagnose from tracebacks alone, and attaching a debugger to an already-running process is often confusing. This Skill provides concrete recipes for interactive debugging with pdb, post-mortem analysis, and remote debugging via debugpy or remote-pdb. ## Core Features & Use Cases - Local pdb debugging: Insert breakpoint() calls, launch scripts under python -m pdb, and use the full pdb command set (step, breakpoints, stack navigation, interact mode). - Pytest integration: Drop into pdb on test failure with --pdb, including the required -p no:xdist workaround for pytest-xdist. - Remote and post-mortem debugging: Attach debugpy to running processes via DAP, inject into a PID, or use remote-pdb over netcat for terminal-friendly sessions; run post-mortem inspection on uncaught exceptions. - Use Case: A gateway subprocess misbehaves in production and cannot be restarted. Add a remote-pdb set_trace call in the suspect handler, trigger the code path, connect with nc 127.0.0.1 4444, and inspect locals and the call stack live. ## Quick Start Add breakpoint() at the suspect line in my Python file and walk me through using pdb commands to inspect the variables when it pauses.

Frequently Asked Questions about python-debugpy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I debug Python code with pdb breakpoints?▼

Insert breakpoint() at the line you want to inspect and run the script normally; execution pauses there with a (Pdb) prompt. Use n to step, s to step into, p to print expressions, and w to view the call stack.

How to debug a running Python process remotely?▼

Use debugpy by adding debugpy.listen(("127.0.0.1", 5678)) and debugpy.wait_for_client() in the code, or launch with python -m debugpy --listen 127.0.0.1:5678. For terminal-only access, remote-pdb's set_trace gives a plain pdb prompt over nc.

debugpy vs remote-pdb: which should I use?▼

Use debugpy when you need IDE integration via the DAP protocol, thread-aware debugging, or attach-to-PID injection. Use remote-pdb when you just want a terminal pdb session over netcat without DAP client complexity.

Why does pdb not work when running pytest?▼

pdb does not work under pytest-xdist, which many test runners enable by default; the prompt never appears and the test hangs. Add -p no:xdist or run a single test with -n 0 to make --pdb work.

Why does debugpy attach to PID fail?▼

Attach fails on hardened kernels where ptrace_scope restricts process injection, such as the Ubuntu default of 1. Set /proc/sys/kernel/yama/ptrace_scope to 0 with root, or launch the process under debugpy from the start.

When should I not use pdb for debugging?▼

Skip pdb when print() or logging solves the problem quickly, or when pytest --tb=long --showlocals already reveals the issue. pdb also does not follow forks, so each child process needs its own breakpoint.