Python Module Installation

Python Module Installation

Sample Installation: healpy Python module

Please reference our documentation to install python in a user directory

Decide on your source directory and obtain the healpy source. I have /home/<caseid>/src for holding the source code of custom packages for installation. So, go to that directory

cd /home/<caseID>/src

Download tar.gz file which results in a tar-ball: healpy-1.9.1.tar.gz

wget https://github.com/healpy/healpy

Unpack healpy-1.9.1.tar.gz, creating directory healpy-1.9.1

tar xzvf healpy-1.9.1.tar.gz

Alternatively, obtain the source code using: > git clone https://github.com/healpy/healpy

set the PYTHONPATH

export PYTHONPATH=/home/<caseID>/<install-path>/lib/python2.7/site-packages/

For me, my install-path looked like:

export PYTHONPATH=/home/<caseID>/local/lib/python2.7/site-packages/

Consider adding the above line to .bashrc

Create a directories to PYTHONPATH

mkdir -p $PYTHONPATH

Load necessary modules (for example):

module load python/2.7.10 

Notes:

-- > module load gcc (default is fine, that will load gcc/4.9.3)

By default, the intel/2015 module should have loaded. The build uses both gcc and intel compilers. Please recall that the OS has a gcc version, but it's rather limited compared with the versions available through modules.

-- > module list (this allow you to verify that the appropriate modules are in fact loaded)

cd to the source directory (see above), which for me was /home/<caseID>/src/healpy-1.9.1

Build:

python setup.py build

This step will take 10-15 minutes.

Run:

python setup.py install --prefix=/home/<caseID>/<install-path>

Notes:

For me this was /home/<caseID>/local, the "root" of the PYTHONPATH

Your choice entirely -- just be consistent throughout the process.

I follow a general linux convention of having separate ../src and ../local directories to manage the source files and the installed files.

This step will take some minutes, and should handle downloading dependencies missing from the system and your user account (perhaps astropy)

Check install:

python

>>> import numpy

>>> import healpy

Notes:

-- The PYTHONPATH environment variable needs to be defined as above.

-- Not only does the python module need to be loaded, but so does gcc. This will allow the package to find needed runtime shared libraries.