about // doc

Quick Reference of IPython

Last modified: Feb, 2014

General info


The installation guide is here. In Ubuntu, it is as simple as

sudo apt-get install ipython

Debugging with IPython

The module ipdb (IPython-enabled pdb) offers extra features that are not available in pdb. As of Ubuntu 12.04, ipdb is not in the repository. But it can be easily installed by pip

sudo apt-get install python-pip
sudo pip install ipdb

To insert a breakpoint to the code is as easy as

import ipdb; ipdb.set_trace()

For example, an example Python script with name “tmp.py” and content as follows:

import ipdb

for n in range(5):
    print "Breakpoint below!"
    print n

After executing the script

python tmp.py

it will enter ipdb debugging mode. There are several shortcut keys for debugging, such as “c” for “continue”, “n” for “next”, “q” for quitting debugging mode, etc.

Some useful posts on debugging with IPython

comments powered by Disqus