How to debug a python script launched by a third party app

After some research, this is the best option I have found. Without any other solution provided, I post it just in case anyone has the same problem.

Python has an integrated debugger: pdb. It works as a module and it doesn't allow to use it if you don't have the window control (i.e. you launch the script).

To solve this there are some coders that have created modules that add a layer on pdb. I have tried some and the most easy and still visual interesting is rpudb (but have a look also to this).

To install it:

pip3 install https://github.com/msbrogli/rpudb/archive/master.zip

(if you install it using the pip3 install rpudb command it will install an old version only valid for python 2)

Then, you use it just adding an import and a function call:

import rpudb
.....
rpudb.set_trace('127.0.0.1', 4444)
.....

Launch the program and it will stop in the set_trace call. To debug it (and continue) open a terminal and launch a telnet like this:

telnet 127.0.0.1 4444

You will have a visual debugger in front of you with the advantage that you can not only debug local programs, but also remote (just change the IP).


I was able to attach PyCharm to a running python process and use break points using PyCharm attach to process

I created a bash script which exec a python script, should work the same with C++