Run a Python script under the VS Code debugger from the terminal, halting on the first line.
Project description
vspdb — VS Code pdb for the terminal
Debug any Python script (with arguments) in the VS Code debugger straight from
the terminal — no hand-written launch.json, no debug.py wrapper.
python -m vspdb my_script.py arg1 arg2
vspdb starts a debugpy debug server, gets VS Code to attach, and halts on the
first line of your script — just like stopOnEntry. It ships a small VS Code
helper (installed automatically) so this works with zero clicks.
Install — one package, that's it
pip install vspdb # (or: pip install -e . from this folder)
That's the only thing you install. vspdb ships a tiny VS Code helper extension inside the package and installs it into VS Code for you on first use. So:
python -m vspdb my_script.py 10 # explicit (or: vspdb my_script.py 10)
The first run prints a one-time note that it installed the helper — reload
the VS Code window once (Ctrl+Shift+P → "Developer: Reload Window"). After
that it's fully automatic.
Tip: install into the same interpreter VS Code uses for the workspace (
Ctrl+Shift+P→ "Python: Select Interpreter") so breakpoints line up. You can also pre-install the helper without running a script:python -m vspdb --setup.
How you use it: zero clicks
Once the helper is active (after that one reload), just run scripts — each one attaches and halts on its first line, no debug panel, no F5:
python -m vspdb my_script.py 10
python -m vspdb another.py --flag
The helper keeps a debugpy listener ready in VS Code (one per window, on a
per-project port) and vspdb connects to the right window automatically.
Don't want the helper? (no-extension fallback)
Run with --no-ext (or set VSPDB_NO_AUTO_EXTENSION=1). Then vspdb won't touch
VS Code; instead it writes two configs to .vscode/launch.json and you attach
manually:
- vspdb: Listen — start it once per window (F5), then runs are zero-click.
- vspdb: Attach — vspdb waits; press F5 once per run.
Options
python -m vspdb [options] <script.py> [script args...]
Everything after the script name is passed to your script untouched (so your
script can use --port, --host, etc. without clashing with vspdb).
| Option | Description |
|---|---|
--port, -p PORT |
Debug port (default: 5678). |
--host HOST |
Debug host/interface (default: 127.0.0.1). |
--listen |
Force listen mode (open the port, wait for VS Code). |
--connect |
Force connect mode (attach to a VS Code that is already listening). |
--no-wait |
Don't wait for VS Code; run immediately (disables stop-on-entry). |
--no-stop |
Attach, but don't halt on the first line. |
--no-launch-json |
Don't create/update .vscode/launch.json. |
--setup |
(Re)install the bundled VS Code helper extension and exit. |
--no-ext |
Don't auto-install the VS Code helper on this run. |
The --port default is read from .vscode/vspdb.json (written by the helper) if
present, else 5678. Disable auto-install globally with VSPDB_NO_AUTO_EXTENSION=1.
Examples:
# Different port
python -m vspdb --port 5690 my_script.py 10
# Your script gets its own --port; vspdb does not consume it
python -m vspdb server.py --port 8080 --debug
# Run under the debugger but don't stop on entry (rely on your own breakpoints)
python -m vspdb --no-stop my_script.py 10
How it works
- Parses
vspdboptions, then treats the first positional as the script and the rest as the script'sargv. - Installs the bundled VS Code helper into VS Code if it isn't there yet (unless
--no-ext), and ensures.vscode/launch.jsonhas the manual-fallback attach configs (merging, never clobbering, any existing file). - Resolves the port: if
--portisn't given, it walks up from the script's directory for.vscode/vspdb.json(written by the auto-listen extension) so it attaches to the window that owns the script's project — important when several VS Code windows are open. Then it connects if that port is being listened on, otherwise listens and waits for VS Code. - Once the client is attached, it runs your script as
__main__with the rightsys.argv, having injected adebugpy.breakpoint()at the first executable line so the debugger halts there. Original line numbers are preserved, so tracebacks stay accurate.
Requirements
- Python 3.8+
debugpy(installed automatically)- VS Code with the Python / Python Debugger extension
Author
Kaustubh — kmhatre14@gmail.com · github.com/kmhatre14
License
MIT. Built with assistance from Claude Opus 4.8.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vspdb-0.1.0.tar.gz.
File metadata
- Download URL: vspdb-0.1.0.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
568a063e9beb02d4863a90554126bddffd19987ea090ff1c11abd8a2008d0f1a
|
|
| MD5 |
3e108d72e6736f1a82617081f20144ca
|
|
| BLAKE2b-256 |
2cc313a7b14b88e0ca4ab8dc2e9cb5f01c2fd1b3f4cf1d297a5e49618b5a97df
|
File details
Details for the file vspdb-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vspdb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bc0255078b1ea22ef243ce255042792158a6ebe6a7e90103a8c43fa896a6bbe
|
|
| MD5 |
9e7c3841f5c111d91b4ed08107fb8a7f
|
|
| BLAKE2b-256 |
8b66583729cc11ff57198de980c517bc3424c6f706c7eeff6fedc20ece3493db
|