Remote IPython notebook with Raspberry Pi

It recently stuck me that I’d really like to do some data analysis on my iPhone. This is pretty impractical because it’s a tiny screen and the keyboard often autocorrects and capitalizes things I don’t want it to, but I still wanted to do it because 1) I can, and 2) why not?.

To do this, I connected my Raspberry Pi up to the router, created a static IP address, set my router to port forward to that IP address, installed IPython and its friends, and set up a remote notebook. Pretty simple stuff!

Static IP

To set up the static IP, I basically followed these directions.

Port forwarding

I have a Netgear router so I just logged in at routerlogin.net, went to port forwarding, and forwarded to my Raspberry Pi’s static IP address at port 9999.

Installing IPython and friends

Since I’m using Raspbian, it’s as easy as:

$sudo apt-get -y install ipython-notebook
$sudo apt-get -y install python-matplotlib python-scipy \
python-pandas python-sympy python-nose

(copied from the IPython install guide)

Setting up a remote notebook

Setting up a remote notebook involved following these instructions.

  1. Set up a profile for the server:

$ipython profile create nbserver

  1. Create a password hash in python:

from IPython.lib import passwd
passwd()

  1. Configure notebook server (change stuff in /home/user/.ipython/profile_nbserver/ipython_notebook_config.py)

c = get_config()

Kernel config

c.IPKernelApp.pylab = ‘inline’

Notebook config

c.NotebookApp.ip = ‘*’
c.NotebookApp.open_browser = False
c.NotebookApp.password = u’hash’
c.NotebookApp.port = 9999

  1. Then to start the server:

ipython notebook –profile=nbserver

The directions are explained much better at the link. But now, I just point my iPhone’s browser at my IP address, and BOOM! I’m ready to be distracted in class.

I also added the line to start up notebooks into rc.local file located /etc/rc.local so that the notebook server starts up each time I log in.
photo
Now scientific computing on a 700 MHz CPU is not ideal, so next I’m going to figure out how to create a cluster of Raspberry Pis, but that will likely wait until summer.