2012/11/04

python tips: set up IPython Notebook on Ubuntu12.04LTS

set up pythonbrew, which makes it easier to maintain multiple python binaries.
# install curl for downloading pythonbrew package
$ sudo apt-get install curl

# install packages for compiling python2.7.3 with pythonbrew
$ sudo apt-get install build-essential, libbz2-dev, libsqlite3-dev, zlib1g-dev, \
                       libxml2-dev, libxslt1-dev, libreadline5, libreadline-dev, \
                       libgdbm-dev, libgdb-dev, libxml2, libssl-dev, tk-dev, \
                       libgdbm-dev, libexpat1-dev, libncursesw5-dev

# install pythonbrew
$ curl -kLO https://github.com/utahta/pythonbrew/raw/master/pythonbrew-install
$ chmod +x pythonbrew-install
$ ./pythonbrew-install

# edit .bashrc then, 
$ source ${HOME}/.pythonbrew/etc/bashrc

# setup python-2.7.3 with pythonbrew
$ pythonbrew install 2.7.3

# change default python binary
$ pybrew switch 2.7.3
set up virtualenv, which provides virtual pythons' executable environment
# install virtualenv
$ pip virtualenv virtualenvwrapper
$ echo "VIRTUALENVWRAPPER_PYTHON=${HOME}/.pythonbrew/pythons/Python-2.7.3/bin/python" >> ~/.bashrc
$ source ${HOME}/.pythonbrew/pythons/Python-2.7.3/bin/virtualenvwrapper.sh
set up ipython notebook.
# get package for pyqt compile
$ sudo apt-get install libqtcore4
$ sudo apt-get install libqt4-dev

# download SIP package from http://www.riverbankcomputing.co.uk/software/sip/download
# install SIP following README
 
# download PyQt package from http://www.riverbankcomputing.co.uk/software/pyqt/download 
# install SIP following README

# install numpy and scipy
$ sudo apt-get install liblapck3gf liblapack-dev libblas3gf libblas-dev gfortran
$ pip install numpy
$ pip install scipy

# install matplotlib
$ sudo apt-get install libpng12-dev libjpeg8-dev libfreetype6-dev
$ pip install matplotlib

# install pyzmq
$ pip install pyzmq

# install tornado
$ pip install tornado

# install pygments
$ pip install pygmenta

# install pandas
$ pip install pandas

# install sympy
$ pip install sympy

# install nose
$ pip install nose

# install ipython
$ pip install ipython
$ easy_install ipython[test]
$ easy_install ipython[zmq,qtconsole,notebook,test]
$ iptest

# install packages for ipython extension
$ sudo apt-get install r-base-core ruby
$ pip install rpy2
$ pip install rtools

100