Saturday 24 January 2015

Install ipython notebook in Ubuntu 14.04

Notes:

1. Install python packages through Anaconda

1.1 Download Anaconda for Linux from the official website:
- http://continuum.io/downloads
- current version is: Anaconda-2.1.0-Linux-x86.sh

1.2 Go to the downloading location:
- $ chmod +x Anaconda-2.1.0-Linux-x86.sh
- $ ./Anaconda-2.1.0-Linux-x86.sh

After installing Anaconda, we have:
- core python (2.7), ipython, ipython notebook interactive IDE, spyder for programming IDE, numpy, scipy, matpolib, ...
- The path to Ananconda has been added to the bash environment .bashrc

2. Set up ipython notebook that it can run remotely

Following instructions are found in website:
http://nbviewer.ipython.org/github/melund/ipython/blob/master/examples/Notebook/Running%20the%20Notebook%20Server.ipynb

2.1 Before running everything, need to update openssl for anaconda
- $ conda update openssl

2.2 Create password for web server from ipython ide
- $ ipython
- In [1] from IPython.lib import passwd
- In [2] passwd() then enter password twice and save the hashed password (ex:
sha1:6c2164fc2b22:ed55ecf07fc0f985ab46561483c0e888e8964ae6' )

2.3 Create default profile ipython_notebook_config.py (which is not exist in ~/.ipython/profile_default/) 
- $ ipython create profile

It will create some default configuration files in the default folder

2.4 Create certificated key and file for accessing to secured ipython web server
- $ cd ~/.ipython/profile_default/
- $ openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.key -out mycert.crt


2.5 Update the configuration file 
- $ nano ipython_notebook_config.py

find and update the following places:


# The full path to an SSL/TLS certificate file.
c.NotebookApp.certfile = u'/home/elendh/.ipython/profile_default/mycert.crt'

# The full path to a private key file for usage with SSL/TLS.
c.NotebookApp.keyfile = u'/home/elendh/.ipython/profile_default/mycert.key'
 
c.NotebookApp.password = 
u'sha1:6c2164fc2b22:ed55ecf07fc0f985ab46561483c0e888e8964ae6' 
 

 
 Press Ctrl+O to write the update to file then Ctrl+X to exit

2.5 Run $ ipython notebook and check on the web browser by 

https://[ip_address_or_localhost]:8888

To auto start this service

$ which ipython

copy the path to ipython

$ sudo nano /etc/rc.local

 add the following line before "exit 0"

su -c "path_to_ipython notebook &"



No comments:

Post a Comment