Python, Numpy and Scipy installation from source without root access
Python, as well as its numerical libraries are one of the essential toolsets for researchers and data scientists. But the installation process is not always so straightforward. In particular, there are some obstacles and pitfalls when you do not have the root priviledge to the servers. One solution to that is to install python and the other libraries from sources code. However, the guides in scipy official site sometimes (or usually) does not work. Here is how I did that with Python 2.7.
My server: CentOS 6.6, GCC 4.4
Compile Python
Download Python 2.7 source code from the official site Python-2.7.tgz
This would place a Python27 on your home directory. --enable-shared
compiles libpython as shared object, which is critical if you want to invoke python code from C/C++ programs.
Then add the path to environmental variable and setup the alias.
bash: edit .bashrc, add
tcsh: edit .cshrc, add
Then install the packages.
nose
Diagnosis library for the others. Download sources from here.
lapack
Download lapack-3.4.2.tgz. The installation will be combined with that of atlas.
atlas
Download atlas3.10.0.tar.bz2. The detailed instruction is inside doc/ folder of the package. The steps:
The configuration take some time. Then compile, check, and install.
ATLAS is installed. Check out the fortran compiler used and remember it.
You may see F77=gfortran
. So for my installation, the compiler is “gfortran”. Remember yours for later references.
numpy
Download numpy-1.8.0.tar.gz. The fortran compiler indicated here and in the scipy installation MUST be consistent with the one your see in the last section, or mistakes will happen.
edit site.cfg
If your fortran compiler is “gfortran”
Otherwise, if your fortran compiler is “g77”
Then finish the installation
scipy
Download scipy-0.13.0.tar.gz. Then steps are similar to those of numpy.
edit site.cfg
If your fortran compiler is “gfortran”
Otherwise, if your fortran compiler is “g77”
Then finish the installation
test for integrity
Start a python console
Install other packages
The installation for other packages are mostly trivial. Generally, download the source packages, unpack them, and type
Most of them are fine with this. Some of packages may require setuptools.
For machine learning projects, these packages are particularly usefull:
matplotlib: matlab-like visualisation library
scikit-learn: implementation of many usefull machine learning algorithms
networkx: good for graph and social network
pybrain: neural networks