如何在库模块 (pdb) 中设置断点 [英] How to set breakpoints in a library module (pdb)
本文介绍了如何在库模块 (pdb) 中设置断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在调试一个 sys.path 看起来像的 python 脚本
sys.path = ['','home/my_library', ..]
我在使用 pdb 时无法在 my_library
的模块中设置断点.该脚本使用以下命令导入库:
将 my_library 导入为 foo
反过来,my_library 通过以下方式提供其模块:
from my_module 导入栏
在我的脚本上运行 pdb 时如何处理 my_module 的代码?
PS:我尝试了以下方法但没有成功:
b my_module:1b my_library.my_module:1b my_library.bar:1b foo.my_module:1b foo.bar:1
解决方案
您使用 文件名 而不是对象名称来限定断点:
<预><代码>>>>导入 pdb>>>导入艺术品 # 我们想在里面打破的模块>>>pdb.set_trace()- 返回 -><控制台>(1)<模块>()->无(Pdb) b 艺术品/models.py:1断点 1 在/home/user/projects/artwork/models.py:1另见这个答案.
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
解决方案
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.
这篇关于如何在库模块 (pdb) 中设置断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文