Search code examples
pythoneclipsedebuggingpydevremote-debugging

How to send a script path in PyDev for debugging instead of inserting settrace in the script?


I'm following a pretty old guide where one could tell PyDev a script path from another application & it would debug it, line by line in eclipse. I like this method, instead of putting settrace() breakpoints in the main script.

scriptpath = "Users/me/Desktop/script.py"
debuggerpath = "/Users/me/.p2/pool/plugins/org.python.pydev.core_7.5.0.202001101138/pysrc"

import pydev_debug as pydevd
pydevd.debug(scriptpath, debuggerpath, trace=True )

Most likely, the api has changed. What is the current method to do the same ?


Solution

  • Well, I'm not sure which guide is this (I don't think there ever was a pydev_debug in PyDev).

    What that module probably did is add pydevd to sys.path and then setup the current tracing in using pydevd.settrace and then called execfile (in Python 2 -- for Python 3 the exec is a bit more contrived... see: https://github.com/fabioz/PyDev.Debugger/blob/master/_pydev_imps/_pydev_execfile.py)

    So, although there's no ready made solution for that, it should be relatively easy to do with the building blocks provided by PyDev.