IPython HTML Notebook

Until recently I had never been a fan of IPython but with their HTML notebook they’ve finally won me over. What I like about this tool is that it makes it easy to go back and forth between interactive prototyping and a script. Being able to continuously edit and re-run code in an interactive session is a powerful tool.

The notebook also makes a great tutorial and demo tool. Here’s a PDF of my session developing a Python replacement for IDL’s GAUSSFIT function.


The IPython notebook requires a few extra packages but if you have a setup like me it’s easy to get everything installed:

brew install zeromq
pip install pyzmq
pip install tornado
pip install ipython

After doing this you may also want to locally install MathJax for JavaScript equation rendering:

from IPython.external.mathjax import install_mathjax

To launch the notebook from whatever directory you want to work in:

ipython notebook

This will launch the IPython notebook dashboard in your default browser, from which you can make new notebooks or resume working on existing ones.

See the docs for all you can do with the notebook, and enjoy!

4 thoughts on “IPython HTML Notebook

  1. Thanks for the instructions! I followed them, and everything works, except only in Google Chrome! On Safari, I get:

    Websocket connection to ws:// could not be established.
    You will NOT be able to run code.
    Your browser may not be compatible with the websocket version in the server, or if the url does not look right, there could be an error in the server’s configuration.

    Any ideas why it doesn’t work with Safari?

    • OK, found the answer.

      pip install tornado

      pip install tornado==2.1

      as the current version of tornado (2.2) has a weird web socket problem with safari… and wasted 2 hours for me to find!

  2. Thanks for posting this, and I’m glad you like the new Notebook. You should check out NotebookCloud. It’s a free web service that lets you create IPython Notebook servers on EC2 in a couple of clicks. It includes a much fuller stack than most setups…

    * Uses the new IPython 0.13 on Ubuntu Server 12.04 LTS

    * Supports all the core IPython features, including inline plotting

    * Full support for R, Cython and Octave magic

    * Support for python3, sh, bash, perl and ruby magic out the box

    * Includes pip, setuptools, Pexpect, nose, Sphinx, Pygments and boto

    * Includes pandas, NetworkX, mpi4py, pyTables and h5py

    * Includes SciKit learn and statsmodels

    There’s a Chrome App available in the Store, just search for IPython. Else, you can just use the regular webapp at notebookcloud.appspot.com.

    Sorry for the plug, and thanks again for telling more people about IPython.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s