Friday, February 12, 2010

How to install NumPy on Solaris

I've been working with NumPy (Numerical Python module) on Solaris, and now have a set of steps to install this and get this working. Note that this is the very basic installation of NumPy and doesn't contain additional libraries like BLAS or LAPACH. You can read more about installing these at the NumPy building instructions page. These instructions are to help you get all of the prerequisites installed and a basic build of NumPy going.

First you will need to install a Fortran compiler. You can download the Sun Studio 12u1 and put it in /tmp. Then:

cd /tmp
bzcat SunStudio12u1-SunOS-x86-tar-ML.tar.bz2 | /bin/tar -xf -
cd SunStudio12u1-SunOS-x86-tar-ML
./SunStudio12u1-SunOS-x86-tar.sh --accept-license
mv sunstudio12.1/ /opt
export PATH=/usr/ccs/bin:/opt/sunstudio12.1/bin:$PATH

From sunfreeware.com, download and install python-2.6.2-sol10-x86-local.gz to /tmp as well. Unpack and install:

gunzip python-2.6.2-sol10-x86-local.gz
pkgadd -d python-2.6.2-sol10-x86-local

Also, similarly install libiconv-1.13.1-sol10-x86-local.gz, gcc-3.4.6-sol10-x86-local.gz, libgcc-3.4.6 and openssl-0.9.8l. When you get to installing libgcc, you get warnings about overwriting existing libraries. This is okay, so, just say yes to overwrite them.

Add the following to /root/.bashrc as well as your current shell:

export PATH=/usr/local/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

Then with these new settings:

cd /tmp
svn co http://svn.scipy.org/svn/numpy/trunk numpy # (if svn is not installed, then svn co on another machine and scp -r to copy it to /tmp)
cd numpy
python setup.py build --fcompiler=sun
python setup.py install

To test the installation, create a file called /tmp/test.py with:

import numpy

Then test that it works. You should get no import errors:

python test.py

1 comment:

david said...

I've got numpy/scipy installed on solaris but routines are running very slow. I'm thinking I need to build ATLAS and link that in but this is not trivial.

Do you have speed tests for your install? I've been posting here and here (sorry if you're already involved under another name!)

http://www.mail-archive.com/numpy-discussion@scipy.org/msg33406.html

http://stackoverflow.com/questions/7311869/python-numpy-on-solaris-blas-slow-or-not-linked