NORDITA logo University of Dundee
MHD Group
Postdoctoral Fellow
Simon Candelaresi
home publications/talks teaching cv computing links pictures/movies

How to setup python with numpy and pylab on Neolith

On Neolith and Ferlin some plotting tools are already installed, like matlab and idl. If one wishes to use python together with pencil code one needs to install the following libraries:
  1. numpy
  2. BLAS
  3. LAPACK
  4. scipy
  5. matplotlib
In order to do the installation as USER one needs to make a local installation. One also needs a fortran compiler. In this HowTo I will use gfortran, so if you use another one just replace it with your compiler. I'm also using bash, so if you use another shell you need to replace the export commands accordingly. Before all create the installation directory in your $HOME
mkdir ~/local

numpy

wget http://sourceforge.net/projects/numpy/files/NumPy/1.4.1/numpy-1.4.1.tar.gz/download
tar -xvzf numpy-1.4.1.tar.gz
cd numpy-1.4.1
python setup.py build --fcompiler=gnu95
python setup.py install --prefix=$HOME/local/
export PYTHONPATH=$PYTHONPATH:/home/x_simca/local/lib64/python2.4/site-packages 

BLAS

wget http://www.netlib.org/blas/blas.tgz
tar -xvf blas.tgz
cd BLAS
gfortran -O3 -m64 -fno-second-underscore -fPIC -c *.f 
ar rv libblas.a *.o
cp libblas.a ~/local/lib64/
ln -s ~/local/lib64/libblas.a ~/local/lib64/libfblas.a
export BLAS=$HOME/local/lib64/libblas.a

LAPACK

wget http://www.netlib.org/lapack/lapack.tgz
tar -xvf lapack.tgz
cd lapack-3.2.1
cp make.inc.example make.inc
# edit make.inc:
OPTS     = -O2 -m64 -fPIC
NOOPT    = -m64 -fPIC
# in the console:
make lapacklib
cp lapack_LINUX.a $HOME/local/lib64/liblapack.a
ln -s $HOME/local/lib64/liblapack.a $HOME/local/lib64/libflapack.a
export LAPACK=$HOME/local/lib64/liblapack.a

scipy

wget http://sourceforge.net/projects/scipy/files/scipy/0.8.0b1/scipy-0.8.0b1.tar.gz/download
tar -xvzf scipy-0.8.0b1.tar.gz
cd scipy-0.8.0b1
python setup.py build --fcompiler=gnu95
python setup.py install --prefix=$HOME/local/
export PYTHONPATH=$PYTHONPATH:$HOME/local/lib64/python2.4/site-packages 

matplotlib

wget http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99.3/matplotlib-0.99.3.tar.gz
tar -xvzf matplotlib-0.99.3.tar.gz
cd matplotlib-0.99.3
python setup.py build
python setup.py install --prefix=$HOME/local/ 

.bashrc

If you use bash edit your ~/.bashrc:
export PYTHONPATH=$PYTHONPATH:$HOME/local/lib64/python2.4/site-packages
export BLAS=$HOME/local/lib64/libblas.a
export LAPACK=$HOME/local/lib64/liblapack.a
export PATH=$PATH:$HOME/local/bin/
Now you can remove all the temporary directories.

How to setup python with numpy and pylab on Ferlin

The configuring under Ferlin is much easier than on Neolith now, thanks to the guys at PDC.
Simply edit your ~/.bashrc if you are using bash:
export PATH=/pdc/vol/python/2.6.5/bin:$PATH
export PYTHONPATH=/pdc/vol/python/2.6.5/lib:/pdc/vol/python/packages/site-python-2.6/lib/python:$PYTHONPATH

References

http://matplotlib.sourceforge.net/users/installing.html
http://ab-initio.mit.edu/wiki/index.php/Template:Installing_BLAS_and_LAPACK
http://www.scipy.org/Installing_SciPy/BuildingGeneral#head-a99e89881841cba43f7091c443a0ccfc9f19f394
http://www.netlib.org/blas/
http://www.mtheory.co.uk/support/index.php?title=Installing_Python_-_iPython%2C_Numpy%2C_Scipy_and_Matplotlib_on_OS_X

home publications/talks teaching cv computing links pictures/movies