IPython Notebook on AWS

How to get IPython notebook running on AWS

Apate Fraus
3 min readDec 9, 2013

Prerequisite:

  1. Launch an instance on your AWS account
  2. SSH into your AWS account
  3. Basic usage of Vim

Launch & SSH into AWS:

  1. Launch Ubuntu Server 12.04.3 LTS 64 bit
  2. Edit security group to allow inbound traffic for ports 22, 443, & 8888
  3. SSH into your instance, should see the below

Install Analytical Toolkit from Continuum:

Run each command only after the previous has finished

  1. wget http://09c8d0b2229f813c1b93-c95ac804525aac4b6dba79b00b39d1d3.r79.cf1.rackcdn.com/Anaconda-1.8.0-Linux-x86_64.sh
  2. bash Anaconda-1.8.0-Linux-x86_64.sh
  3. Agree to license
  4. Install in default location
  5. When asked, “Do you wish the installer to prepend the Anaconda install location to PATH in your /home/ubuntu/.bashrc ?” Type Yes.
  6. source .bashrc (This reloads your bash settings)
  7. Test that everything is working by typing ipython, you should see:

Set up IPython Notebook:

  1. from IPython.lib import passwd
  2. passwd()
  3. Enter your secret password and record the sha1 output to be used later
  4. cd
  5. !mkdir certificates
  6. cd certificates/
  7. !openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem
  8. Your screen should look like this:

Keep hitting enter to all the questions, this portion creates an SSL certificate. Now exit out of iPython.

Create Notebook Profile:

  1. ipython profile create nbserver
  2. cd ~/.ipython/profile_nbserver/
  3. vim ipython_notebook_config.py
  4. Add the code below to the file:

#Kernel Config
c.IPKernalApp.pylab = ‘inline’
#Notebook config
c.NotebookApp.certfile = u’/home/ubuntu/certificates/mycert.pem’
c.NotebookApp.ip = ‘*’
c.NotebookApp.open_browser = False
c.NotebookApp.password = u’sha1:bc….your sha1 from up above’
c.NotebookApp.port = 8888

It should look like:

Launching iPython Notebook, almost done : ), I promise:

  1. cd
  2. mkdir notebooks
  3. cd notebooks
  4. ipython notebook inline —profile=nbserver
  5. Now it will ask you all sorts of questions, just hit ‘q’ until you see this:

Last Steps:

  1. Find out your public dns from amazon ec2 control panel
  2. Open up chrome/firefox and navigate to https://your_public_dns.us-west-2.compute.amazonaws.com:8888/
  3. Your browser will yell at you that the SSL is fraudulent, proceed anyways.
  4. Enter password and viola:

Credit:

I reorganized the information presented here. Thank you iamatypeofwalrus!

Troubleshooting:

To use %pylab, you may need to install:

sudo apt-get install libsm6
sudo apt-get install libxrender1
sudo apt-get install libfontconfig

Then use %pylab inline at the top of your iPython notebook

If you want to keep the instance running even when you disconnect from aws:

nohup ipython notebook inline —profile=nbserver

--

--