问题
I am debugging a python script which sys.path looks like
sys.path = ['','home/my_library', ..]
I'm having troubles to set a breakpoint in a module from my_library
while using pdb.
The script imports the library with:
import my_library as foo
In turn, my_library makes its module(s) available by:
from my_module import bar
How can address my_module's code while running pdb on my script?
PS: I have tried the followings without success:
b my_module:1
b my_library.my_module:1
b my_library.bar:1
b foo.my_module:1
b foo.bar:1
回答1:
You qualify the breakpoints with the filename, not the object name:
>>> import pdb
>>> import artwork # module we want to break inside
>>> pdb.set_trace()
--Return--
> <console>(1)<module>()->None
(Pdb) b artwork/models.py:1
Breakpoint 1 at /home/user/projects/artwork/models.py:1
See also this answer.
来源:https://stackoverflow.com/questions/23071175/how-to-set-breakpoints-in-a-library-module-pdb