2 minute read

Basic Installation Flow

Thanks to Kenarius Octonotes, I basically followed his article Install Up-to-date Scientific Environment in Ubuntu 14.04 With Python 3.4. The installation flow goes like this (with some modification with Kenarius’ note):

#!/usr/bin/env bash

# change to root
sudo su

# 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 dependencies for matplotlib
apt-get install -y libfreetype6-dev libpng-dev

# install numpy
apt-get install python3-numpy

# exit from `sudo su`
exit

# ipython notebook has bug:
# https://bugs.launchpad.net/ubuntu/+source/python3.4/+bug/1290847

python3 -m venv --clear --without-pip venv/ipython-notebook

# activate virtual env and install pip
source venv/ipython-notebook/bin/activate

# (1) DO NOT switch to `easy_install pip` in the middle of the installation flow
wget https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
rm get-pip.py

# install scientific packages
sudo -H pip3 install numpy sympy matplotlib scipy pandas

# install ipython notebook and dependencies
sudo -H pip3 install ipython pyzmq jinja2 pygments bokeh

# install latest dev scikit-learn and build it
# sudo -H pip3 install cython https://github.com/scikit-learn/scikit-learn/archive/master.zip

# You don't have to use the latest version of scikit-learn
sudo -H pip3 install cython scikit-learn

# install prettyplotlib by Olga Botvinnik for beauty plots
sudo -H pip3 install brewer2mpl prettyplotlib

# install ipython and notebook, jupyter and patsy
sudo -H pip3 install ipython[notebook]
sudo -H pip3 install jupyter
sudo -H pip3 install patsy

# start notebook. current folder will be your workspace
sudo ipython notebook

# deactivate venv, complementary to `source venv/ipython-notebook/bin/activate`
deactivate

However, there might be some problems.

Problem 1: invalid command ‘egg_info’

The solution is provided in stackoverflow: Can’t install via pip because of egg_info error:

Found out what was wrong. I never installed the setuptools for python, so it was missing some vital files, like the egg ones.

If you find yourself having my issue above, download this file and then in powershell or command prompt, navigate to ez_setup’s directory and execute the command python ez_setup.py and this will run the file for you.

But please don’t change to easy_install pip, which is suggested in the above post, in the middle way.

If you did got some trouble from easy_install pip, you can check stackoverflow: How do I remove packages installed with Python’s easy_install?.

Problem 2: No module named notebook.notebookapp

According to stackoverflow: ImportError: No module named notebook.notebookapp, the solution is:

For 4.0 and above You need to install the notebook app separately from https://github.com/jupyter/notebook

pip install jupyter

How to check the versions of your packages?

pip freeze

Problem 3: Unrecognized alias

The profile mechanism changed, so you don’t have to create profile under ~/.ipython/, as stackoverflow: IPython notebook won’t read the configuration file says:

IPython has now moved to version 4.0, which means that if you are using it, it will be reading its configuration from ~/.jupyter, not ~/.ipython. You have to create a new configuration file with

jupyter notebook --generate-config

and then edit the resulting ~/.jupyter/jupyter_notebook_config.py file according to your needs.

More installation instructions here.

Categories:

Updated:

Comments