Skip to content

Switching over from `ptvsd` to `debugpy`

Karthik Nadig edited this page Feb 26, 2020 · 1 revision

Switching over from ptvsd to debugpy

Switching from import ptvsd to import debugpy

ptvsd API debugpy API Comments
break_into_debugger() breakpoint()
N\A configure()
debug_this_thread() debug_this_thread()
is_attached() is_client_connected()
enable_attach(address=(host, port)) listen((host,port))
N\A. Passed as a parameter to enable_attach log_to()
trace trace_this_thread()
wait_for_attach() wait_for_client()

Sample code

With ptvsd:

import ptvsd
ptvsd.enable_attach(('localhost', 5678))
ptvsd.wait_for_attach()


ptvsd.break_into_debugger()
print('break here')

With debugpy:

import debugpy
debugpy.listen(('localhost', 5678))
debugpy.wait_for_client()


debugpy.breakpoint()
print('break here')

Switching from ptvsd CLI to debugpy CLI

ptvsd debugpy Comments
--host '<address>' --listen [<address>]:<port>
--port '<port>' --listen [<address>]:<port>
--log-dir <path> --log-to <path>
--log-stderr --log-to-stderr
--wait --wait-for-client
--no-subprocesses N\A

Sample CLI

with ptvsd:

> python ptvsd --host localhost --port 5678 --wait ./myscript.py

With debupy:

> python debugpy --listen localhost:5678 --wait-for-client ./myscript.py