Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pdb: set a breakpoint on file which isn't in sys.path

Tags:

python

pdb

I'm writing a python package and I want to use pdb to debug it. When I try to set break point in one of the files, I get an error:

The specified object 'CaptureManager.frame' is not a function or was not found along sys.path

I googled it, and found a solution:

append the directory which contains my file into sys.path

sys.path.append(os.path.join(os.getcwd(),"project_cameo"))

But after few times, I get very annoyed, because I have to do it every time I restart my debug session. Is there a 'smart' way of doing it?

like image 956
scott huang Avatar asked Sep 20 '17 08:09

scott huang


1 Answers

According to this answer you can also set a break point by writing the full path to filename (or path relative to directory on sys.path)

For example

b /path/to/module.py:34
> Breakpoint 1 at /path/to/module.py:34
like image 77
berkelem Avatar answered Sep 19 '22 00:09

berkelem