Here is a reference to have a local installation of python, only useful as a user without root privileges. Of course, a proper installation using the given GNU/Linux package manager is highly recommended, if enough privileges can be obtained to operate on the system. Full python installations are also available, e.g., Anaconda, and should be considered before taking the steps described below.
Contents
mkdir ~/.local
Download python source files, e.g.,wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz
./configure --prefix=$HOME/.local
make
make install
PYTHONPATH="${PYTHiONPATH}:$HOME/.local/lib/python2.7/site-packages/"
export PYTHONPATH
alias python=$HOME/.local/bin/python2.7
python --version
python setup.py install --prefix=~/.local
cd ~/
python -c "import numpy"
gives no error. The module is then installed. Proceed similarly for other modules, like scipy, Cython, ipython, matplotlib.
mkdir -p ~/src/
cd ~/src/
wget http://www.netlib.org/blas/blas.tgz
tar xzf blas.tgz
cd BLAS
## NOTE: The selected fortran compiler must be consistent for BLAS, LAPACK, NumPy, and SciPy.
## For GNU compiler on 32-bit systems:
#g77 -O2 -fno-second-underscore -c *.f # with g77
#gfortran -O2 -std=legacy -fno-second-underscore -c *.f # with gfortran
## OR for GNU compiler on 64-bit systems:
#g77 -O3 -m64 -fno-second-underscore -fPIC -c *.f # with g77
gfortran -O3 -std=legacy -m64 -fno-second-underscore -fPIC -c *.f # with gfortran
## OR for Intel compiler:
#ifort -FI -w90 -w95 -cm -O3 -unroll -c *.f
# Continue below irrespective of compiler:
ar r libfblas.a *.o
ranlib libfblas.a
rm -rf *.o
export BLAS=~/src/BLAS/libfblas.a
To install Lapack:
mkdir -p ~/src
cd ~/src/
wget http://www.netlib.org/lapack/lapack.tgz
tar xzf lapack.tgz
cd lapack-3.5.0/
cp INSTALL/make.inc.gfortran make.inc # on Linux with lapack-3.2.1 or newer
Then modify make.inc with the following compilation options
OPTS = -O2 -fPIC
NOOPT = -O0 -fPIC
make lapacklib
make clean
export LAPACK=~/src/lapack-3.5.0
python setup.py install --user
cd ~/
python -c "import scipy"
./configure --prefix=$HOME/.local/
make
make install
./configure --prefix=$HOME/.local/
make check
make install
export PATH=/usr/local/bin:$HOME/.local/:$PATH
export LD_LIBRARY_PATH=~/.local/lib/:$LD_LIBRARY_PATH
python setup.py build
python setup.py install --prefix=~/.local/