ipython doesn't work with built-in pdb debugger. While I tried to debug a python script with "
run -d script.py" within ipython shell, I got bellow error:
AttributeError: Pdb instance has no attribute 'curframe'
To debug script in ipython, we need to use a different debugger, pydb, for example. There are only three steps to setup and use it.
- download and install pydb.
- start ipython with -pydb argument: ipython -pydb
- start debugging with: run -d script.py
It's mandatory to set HOME environment variable to use pydb. On my windows box, there is no HOME environment variable set by default, and I got bellow error:KeyError: 'HOME'
It can be solved by adding HOME environment variable.
Because pydb use the same set of commands with gdb, it's fairly straightforward to get start with it if you have done some debugging in gdb. This is one reason why I pick it as my debugger.
Reference:
Introducing the pydb Debugger
Debugging in Python