How to build ScipPy with Python 2.7.2 on CentOS5

EDIT: added –enable-shared to configure script for building Python, and added /home/yourname/lib to shared library path.  This is necessary for building some packages such as pycairo (which you may need to build pygtk and matplotlib).

EDIT 2: you should use the –prefix=/home/yourusername instead of –user.  The prefix option places packages in the standard location: /home/yourusername/lib/python2.7/site-packages.  The –user option places the packages in /home/yourusername/.local/lib/python2.7/site-packages which I think is screwed up!

 

I use CentoOS5 because I want enterprise-class stability, as well as binary compatibility with a commercial application that is built for RHEL5.  I need to use some “bleeding edge” packages, such as the latest version of SciPy, but I don’t want to affect the base stability of the system.  Here is how I did it.  First, with superuser privileges, use yum to install the following packages.  You may need to set up epel as an alternate repository:

  • readline-devel
  • python-devel
  • blas
  • lapack
  • atlas
  • blas-devel
  • lapack-devel
  • atlas-devel

If you are going to install iPython (which I highly recommend) you will also need to install:

  • sqlite-devel

Installing the “-devel” packages is critical!  The basic packages install libraries that end in *.so.3, which cannot be used to link newly built applications.  The -devel packages include libraries that end in *.so that are required for building Scipy.

Now, without superuser privileges, download Python 2.7.2, NumPy 1.6.1, and SciPy 0.9.0 to your home directory.

Building Python 2.7

cd Python-2.7.2
LDFLAGS='-L/usr/lib64' ./configure --prefix=/home/cfinch --enable-shared
make
make install

The LDFLAGS variable tells configure where to find libraries like sqlite, which will be needed if you want to build iPython.  A Python binary should now be installed in /home/yourname/bin/python2.7.  You have to type python2.7 to use the new one; if you just type python you will get the system-wide Python 2.4 interpreter.  You don’t want to change the default to 2.7 unless you really know what your are doing, because important system tools depend on having 2.4 as the default.  Finally, set your LD_LIBRARY_PATH environment variable to include /home/cfinch/lib:

export LD_LIBRARY_PATH='/home/cfinch/lib':$LD_LIBRARY_PATH

Building NumPy

tar xfz numpy-1.6.1.tar.gz
cd numpy-1.6.1

Now, copy the file site.cfg.example to site.cfg and make the following changes:

[DEFAULT]
#library_dirs = /usr/local/lib
#include_dirs = /usr/local/include
library_dirs=/usr/lib64/atlas

This tells the installation process where to find the library files for BLAS, LAPACK, and ATLAS. Now, we can install NumPy with:

python2.7 setup.py install --prefix=/home/cfinch

Building SciPy

tar xfz scipy-0.9.0.tar.gz
cd scipy-9.0.0
python2.7 setup.py install --prefix=/home/cfinch

Finally, download, build, and install iPython per the instructions. It won’t work unless you built Python with sqlite support, as described above.

 

One thought on “How to build ScipPy with Python 2.7.2 on CentOS5

  1. Pingback: How to build ScipPy with Python 2.7.2 on CentOS5 | shocksolution.com | Code IT | Scoop.it

Leave a Reply