Breakpoint not hit from a file that was executed from another file

Answered

I have a call from inside 1 file test.py to open another file but the breakpoints are not hit on the file that is called and executed by os.system

test.py

cmd = 'python eval_single_pair.py'
os.system(cmd)

In this case the debugger should hit breakpoints set in eval_single_pair.py
0
4 comments

This is not supported at the moment. Please vote for the corresponding feature request https://youtrack.jetbrains.com/issue/PY-39222

0
Avatar
Permanently deleted user

It looks like it is according to help file https://www.jetbrains.com/help/pycharm/debugger-python.html

I have Attach to subprocess automatically while debugging checked.

 

 

0
Avatar
Permanently deleted user

I love Pycharm but if anyone really needs this then try Wing IDE Python https://wingware.com/
Here are the docs that show how to use Wing to debug a subprocess https://wingware.com/doc/debug/debugging-externally-launched-code


It works great. Hopefully JetBrains can add this functionality.

0
Avatar
Permanently deleted user

Hi, 

This can be achieved via `subprocess` and I have tested it works. Also note the official python docs where they state that "subprocess module is intends to replace os.system and os.spawm*".

Just do

import subprocess

subprocess.run(["python" , "eval_single_pair.py"]) 

0

Please sign in to leave a comment.