Install Jupyter Notebook and Scientific Environment in Ubuntu 14.04 With Python 3

Several changes occured since my last note about installing python scientific environment:

Install prerequisities as root:

# install curl virtualenvwrapper
apt-get install -y curl virtualenvwrapper

# install as workaround for
apt-get install -y pkg-config

# install python development packages and g++
apt-get install -y python3-dev g++

# install dependencies for scipy
apt-get install -y libblas-dev liblapack-dev gfortran

# install some dependencies for matplotlib
apt-get install -y libfreetype6-dev libpng-dev libjpeg8-dev

Now create and activate virtualenv, install all the packages via pip:

# create and activate virtual environment using mkvirtualenv wrapper (env name is jupnb)
mkvirtualenv --no-setuptools --python /usr/bin/python3.4 jupnb

# install fresh pip
curl | python

# install fresh setuptools
pip install setuptools distribute

# install numpy as it is dependecy for many others
pip install numpy

# install scientific packages (seaborn instead of matplotlib for pretty plots)
pip install sympy scipy seaborn pandas jupyter

# install scikit-learn separately, it depends on numpy and scipy
pip install scikit-learn

# deactivate venv

Configure notebook profile with SSL encryption. Use real ssl certificate instead of self-generated (if you have one). You can use jupyter notebook --generate-config command to create default config with comments about all the options, or use following snippet for minimal config generation:

mkdir -p ~/.jupyter
cd ~/.jupyter
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout ${ENV}.pem -out jupnb.pem
echo "c.NotebookApp.ip = '*'" >>
echo "c.NotebookApp.port = 8888" >>
echo "c.NotebookApp.open_browser = False" >>
echo "c.NotebookApp.password = u'$(ipython -c 'from notebook.auth import passwd; print(passwd())')'" >>
echo "c.NotebookApp.certfile = u'jupnb.pem'" >>
echo "c.NotebookApp.cookie_secret_file = '$HOME/.jupyter/secret_cookie'" >>
cd -

That’s all. To use notebook, activate virtual env, run server and open in your browser:

workon jupnb
jupyter notebook