17

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
Martijn Pieters
  • 963,270
  • 265
  • 3,804
  • 3,187
Niccolò
  • 2,523
  • 3
  • 26
  • 37

1 Answers1

26

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.

Community
  • 1
  • 1
Two-Bit Alchemist
  • 16,887
  • 5
  • 44
  • 79
  • 3
    ah yes, the point was to put the slash, not the dot! Doh! What we would call a Columbus' egg!! Solution is then `b my_library/my_module`. Thanks a lot :-) – Niccolò Apr 14 '14 at 22:36