How to set breakpoint in another module (don't set it on function definition line, if you want to break when function starts being executed)

You are setting the breakpoint correctly. I imagine it is not stopping because the line of code you are breaking on is not called. Put the break on line 383.


You can also set the breakpoint directly with the file and line number, without having to import either sys or another_module.

(Pdb) b /home/user/path/to/another/module/another_module.py:383
Breakpoint 1 at /home/user/path/to/another/module/another_module.py:383

Note that /home/user/path/to/another/module/another_module.py needs to be imported and line 383 needs executable and in the path of execution for it to break, as others have pointed out.

For more help, type help b (or for that matter help followed by any other command) to get more information on that command.

Tags:

Python

Pdb