debugging python script in ipython

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.
  1. download and install pydb.
  2. start ipython with -pydb argument: ipython -pydb
  3. 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

posted on 2010-06-29 20:41  rxwen  阅读(297)  评论(0编辑  收藏  举报

导航