Jake Schwind

iPython Notebook

June 19, 2012 | developmentibmpython

My mentor at IBM turned me on to using the Notebook feature of iPython. This is really cool!

Now, the Python CLI does its job. I have been using it for a while for testing modules and code ideas but usually need documentation open when trying out a new module or I need to look over my own code when I have forgotten what the names in my library are.

iPython is interactive (hence “i”). Via the command line you can use tab completion to quickly finish what you were typing or to see what is available from the module or class. Also, iPython allows you to do basic procedures that I usually find myself exiting the shell for…listing a directory, removing a file, changing the working directory, etc. This is cool, but it gets better.

Using the Notebook feature will allow you to access iPython via a web page. It supports tab completion but does it in a very nice way – drop down lists wherever you are at in a line and it completes code, lists available methods, and completes directory/filenames as well.

After doing a lot of testing and research in the web console, you can save your Notebook so you can pick up where you left off later or just print it for reference. Also check out the graphing abilities with MatPlotLib…graphs show up inline!

So, if you are like me, you are wondering how to use this feature the blogger is babbling on about. Let’s do it!

Linux Install

First, install ZeroMq:

wget http://download.zeromq.org/zeromq-2.2.0.tar.gz
tar -xf zeromq-2.2.0.tar.gz
cd zeromq-2.2.0
make install

Next, install iPython:

pip install ipython

You should be done unless you do not have pip installed

RedHat/CentOS/Fedora: yum install pip

Ubuntu/Debian: sudo apt-get install pip

Ready to Rock!

To start Notebook, run the following command:

ipython notebook

It will start the server and pop up your default web browser and take you to the interface.

If you are trying to install this on a remote server, you can set up the config file to allow connections from any IP address but make sure you put a password on it! I don’t think I need to provide info on this as those who need this feature should know how to find out 🙂