IPython Notebook on AWS
How to get IPython notebook running on AWS
Prerequisite:
- Launch an instance on your AWS account
- SSH into your AWS account
- Basic usage of Vim
Launch & SSH into AWS:
- Launch Ubuntu Server 12.04.3 LTS 64 bit
- Edit security group to allow inbound traffic for ports 22, 443, & 8888
- SSH into your instance, should see the below
Install Analytical Toolkit from Continuum:
Run each command only after the previous has finished
- wget http://09c8d0b2229f813c1b93-c95ac804525aac4b6dba79b00b39d1d3.r79.cf1.rackcdn.com/Anaconda-1.8.0-Linux-x86_64.sh
- bash Anaconda-1.8.0-Linux-x86_64.sh
- Agree to license
- Install in default location
- When asked, “Do you wish the installer to prepend the Anaconda install location to PATH in your /home/ubuntu/.bashrc ?” Type Yes.
- source .bashrc (This reloads your bash settings)
- Test that everything is working by typing ipython, you should see:
Set up IPython Notebook:
- from IPython.lib import passwd
- passwd()
- Enter your secret password and record the sha1 output to be used later
- cd
- !mkdir certificates
- cd certificates/
- !openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem
- 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:
- ipython profile create nbserver
- cd ~/.ipython/profile_nbserver/
- vim ipython_notebook_config.py
- 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:
- cd
- mkdir notebooks
- cd notebooks
- ipython notebook inline —profile=nbserver
- Now it will ask you all sorts of questions, just hit ‘q’ until you see this:
Last Steps:
- Find out your public dns from amazon ec2 control panel
- Open up chrome/firefox and navigate to https://your_public_dns.us-west-2.compute.amazonaws.com:8888/
- Your browser will yell at you that the SSL is fraudulent, proceed anyways.
- 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