setup an iPython notebook
Let’s setup an iPython notebook shall we? First we need to check what
version of iPython we have, this is as easy as typing this in your
terminal:
$> ipython --version
as of right now, the latest version is 1.0.0, if you have anything
less than that you may want to consider upgrading. The easiest way to
do this is via pip.
PIP INSTALLATION
Type pip in terminal and see if you have it, I’ll wait…ok you
don’t? Well follow the link and download it, then to install you
un-tar the file and cd into the directory, then in terminal:
$> python setup.py build
$> python setup.py install
that second command may require sudo depending on your python
installation.
IPYTHON UPGRADE!
Now that you have pip installed you have something very similar to
ubuntu’s apt-get or fedora’s yum, except for python! Now we can
upgrade iPython via pip:
$> pip install ipython --upgrade
Create a new iPython profile
Next we create a new iPython profile:
$> ipython profile create username
where you replace “username” with a profile name of your choice. Then
we edit the file
~/.ipython/profile_username/ipython_notebook_config.py in your
editor of choice; We’re concerned with two lines in particular:
c.IPKernelApp.pylab = 'inline'
c.FileNotebookManager.notebook\_dir = u'/Users/bob/Dropbox/research/python/ipyNotebooks'
These two lines are commented out by default. The first says to put
matplotlib figures in the notebook rather than open a new window, and
the second dictates where the notebooks are saved by default. I like
to set this second option to somewhere in my dropbox so that I can
automatically share those between my multiple machines.
Launch!
Finally we create an alias to launch the notebook as it makes things
much easier. Edit your ~/.bash_profile (mac) or ~/.bashrc (*nix) and
add:
alias notebook='ipython notebook --profile=username'
Once this is done close all of your terminals and open a fresh one.
Type ‘notebook’ and whala, your browser will open to your very own
iPython notebook. I typically minimize this terminal window and keep
it open for extended periods of time so the notebook stays alive.
There are numerous other settings you can dink around with in ~/.ipython/profile_username/ipython_notebook_config.py that I didn’t cover today, so feel free mess around in there. Lastly there are some additional security options to setup a password and such for your notebook that were also not covered, more details about this and credit for the bulk of these instructions comes from here.