我正在编写一个 python 包,我想使用 pdb 来调试它。当我尝试在其中一个文件中设置断点时,出现错误:
The specified object 'CaptureManager.frame' is not a function or was not found along sys.path
我google了一下,找到了解决办法:
将包含我的文件的目录附加到 sys.path
sys.path.append(os.path.join(os.getcwd(),"project_cameo"))
但是几次之后,我变得非常恼火,因为每次重新启动调试 session 时我都必须这样做。有没有一种“聪明”的方法来做到这一点?
最佳答案
根据 this answer您还可以通过写入文件名的完整路径(或相对于 sys.path
上的目录的路径)来设置断点
例如
b /path/to/module.py:34
> Breakpoint 1 at /path/to/module.py:34
关于python - pdb:在不在 sys.path 中的文件上设置断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46317180/