Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(How) can I use pydevd on the command line similar to pdb?

Tags:

python

pdb

pydev

I know that I can debug Dummy.py on the command line like this:

python -m pdb Dummy.py

Now, I am trying to understand some behavior of the debug console in Visual Studio Code which I believe I might track down to behavior of pydevd. (Basically, the debug console reports incorrect error messages for lines such as a = no_existing_function().)

So what I would like to do is use pydevd in a similar way to pdb above, but I fail to achieve that. I have already managed to start a "server",

import pydevconsole
pydevconsole.start_server('localhost', 5678, 1234)

and start a "client" and connect to the above server:

import pydevd
from _pydevd_bundle import pydevd_comm

print(pydevd_comm.start_client('localhost', 5678))
pydevd.settrace()

However, I am unsure what to do next. It seems to me like pydevd is only an intermediary expecting something else to connect to the port which I have chosen to be 1234. But what is it actually expecting there? Can I connect with something like telnet, or short-circuit this connect altogether to get a truely interactive console where I can type commands to be evaluated in the scope of Dummy.py?

like image 636
bers Avatar asked Dec 28 '25 11:12

bers


1 Answers

If you're using visual studio code, you want to use ptvsd instead of pydevd (ptvsd wraps pydevd to use with visual studio code).

See: https://code.visualstudio.com/docs/python/debugging for details (you have to start the remote debugger and then connect to it with a launch configuration).

like image 182
Fabio Zadrozny Avatar answered Dec 31 '25 02:12

Fabio Zadrozny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!