Ipython

Benefits

Is “An Enhanced Interactive Python”. Install it with (see Wajig (Package Management)):

wajig install ipython

It has many great features, but these are the best:

  1. Tab-Completion.

  2. “Dynamic object information”

    try import os and then os? for basic info and os?? for the source

  3. type %edit file.py to edit and run file.py

    for this to work, you should set the EDITOR-variable to your favorite editor, e.g.:

    echo 'export EDITOR=/usr/bin/vim' >> $HOME/.bashrc
    source $HOME/.bashrc
    
  4. Scientists love it ;)

Make IPython aware of virtualenvs

Tested with IPython 0.12 on Ubuntu 12.04 (precise).

Create ipython profile:

ipython profile create

Modify /usr/bin/ipython to look like this (download):

#!/usr/bin/env python
"""Terminal-based IPython entry point.
"""

# --[ HACK to make ipython virtualenv-aware ]--
# see http://isbullsh.it/2012/04/Embed-ipython-in-virtualenv/
from os import environ
import sys
if 'VIRTUAL_ENV' in environ:
    sys.path.append('/usr/lib/python2.7/dist-packages')
    # fix ImportError: No module named _simplegeneric
    # http://stackoverflow.com/questions/11573844/ipython-import-failure-and-python-sys-path-in-general
    sys.path.append('/usr/lib/pymodules/python2.7')
del sys, environ
# --[ end of HACK ]--

from IPython.frontend.terminal.ipapp import launch_new_instance

try:
  launch_new_instance()
except ImportError as e:
  if "qt.console.qtconsoleapp" in e.message:
    print "Could not start qtconsole. Please install ipython-qtconsole"
  elif "html.notebook.notebookapp" in e.message:
    print "Could not start notebook. Please install ipython-notebook"
  else:
    # if there is no clue on the cause -- just re-raise
    raise

Copy virtualenv.py to ~/.config/ipython/profile_default/startup/.

Enjoy!

Sources: