python-debugpy

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

Updated Jun 5, 2026
One-click install
npx skills add https://github.com/xu1713/openhorse --skill python-debugpy-xu1713
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-debugpy
Source: https://github.com/xu1713/openhorse/tree/main/openhorse/openhorse/skills/software-development/python-debugpy
Command: npx skills add https://github.com/xu1713/openhorse --skill python-debugpy-xu1713

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires debugpy, remote-pdb.

What problem does it solve? Tracebacks and print statements often fail to reveal why a value is wrong, especially in long-running processes, subprocesses, or tests that only fail under specific conditions. This Skill provides structured recipes for interactive Python debugging with pdb and remote debugging with debugpy. ## Core Features & Use Cases - Local pdb debugging: Insert breakpoint() for an interactive REPL, launch scripts under python -m pdb, or drop into pdb on pytest failures with --pdb. - Post-mortem inspection: Catch exceptions and inspect locals at the crash frame using pdb.post_mortem or a custom sys.excepthook. - Remote debugging with debugpy: Attach to already-running processes via DAP, inject into a PID, or use remote-pdb for a terminal-friendly pdb session over a socket. - Use Case: A gateway subprocess misbehaves and cannot be restarted cleanly. Add remote_pdb.set_trace() in the suspect handler, trigger it, then connect with nc 127.0.0.1 4444 to inspect the live stack. ## Quick Start Add a breakpoint() call at the suspect line in my Python file and walk me through inspecting the variables when execution pauses there.

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 commands like n to step, p to print expressions, and w to view the call stack.

How to attach a debugger to a running Python process?

Use debugpy with python -m debugpy --listen 127.0.0.1:5678 --pid <pid> to inject into a running process, then connect a DAP client. Alternatively, add remote_pdb.set_trace() in the code and connect via nc to get a standard pdb prompt.

debugpy vs remote-pdb: which should I use?

Use remote-pdb when you want a simple terminal pdb session over a socket, which suits agent-driven or headless debugging. Use debugpy when you need IDE integration, thread-aware debugging, or DAP protocol features.

Why does pdb not work under pytest-xdist?

pdb does not function under pytest-xdist because tests run in worker processes without a terminal; the prompt never appears and the test hangs. Add -p no:xdist or -n 0 to run tests serially so pdb can attach to your terminal.

Why is my breakpoint() call not hitting?

Check whether PYTHONBREAKPOINT=0 is set, which disables all breakpoint() calls. Also verify you are not running under pytest-xdist and that execution actually reaches the line before the process exits.

Can pdb debug multithreaded or asyncio Python code?

pdb only debugs the current thread and does not follow forks, so each thread or child process needs its own breakpoint. For multithreaded code use debugpy, which is thread-aware; for asyncio, await works in pdb only on Python 3.13+.