Python without root privileges - linux

It is often desirable to be able to install additional modules and packages for use with python and have the ability to edit and update such modules, particularly if you are using development versions. On many managed desktops and any clusters user access will be restricted and the necessary directories, so we need to set up the environment so that the additional modules and packages can be stored and accessed from the user $HOME space.

To begin with we need to create a local directory in the home space in the python path. Open a terminal (Ctrl-Alt-t) and at the command prompt ($) type
$ mkdir -p .local/lib/python2.7/site-packages
or if you are already in a terminal and not in the $HOME directory
$ mkdir -p ~/.local/lib/python2.7/site-packages

Replace 2.7 in the lines above, with the version which you wish to apply. Here 2.7 is chosen, because the modules astropy and sunpy have dependencies based on 2.7 and may not work with python3.

So that this directory is in the python path open in a test editor the file ~/.bashrc and add the lines
PYTHONPATH=+${HOME}/.local
export $PYTHONPATH
then save and close the file. This will add the directory to the python path. To apply this to the open terminal
$ source ~/.bashrc

Then we require some common packages for use in astrophysics and solar physics
To install astropy download the latest version as a tarball from https://pypi.python.org/pypi/astropy and extract it to a convenient location (Downloads) then
$ python setup.py develop - -prefix=~/.local
to install astropy in your home space.

To install pysac without root access, it is convenient to use Anaconda or on a cluster where the $HOME space quota will be limited Miniconda. The former will be a comprehensive install, whereas the latter will be a minimal and then you select only your specific requirements.

Using the Miniconda on a linux machine download the appropriate bash installer. From the command line
$ sh Miniconda-latest-Linux-x86_64.sh
(or the particular installer version for your machine) The installation shall run.

You will be prompted where to install the package. It may well exceed a Gb, so a typical cluster quota will not accommodate the package in your $HOME. Therefore seek to locate the package, where there is no quota, or a sufficiently large quota. Also on a cluster where you may be using parallel clusters it is important that the location of the package should be visible from the computational nodes.

You will also be prompted to add it to the $PATH in your .bashrc file, which is recommended to avoid doing so manually at every new login.

Having completed the installation of Miniconda any required packages will then need to be installed as follows
$ conda install astropy
$ conda install mayavi
$ conda install scipy

Colormath is also required and cannot be installed using conda. Download the tar file from [https://pypi.python.org/pypi/colormath/ ] extract the tar then
$ cd colormath-2.1.1
$ python setup.py install - -prefix=/triton/ics/scratch/users/gentf1/miniconda/
(replacing the path of my installation on the triton cluster /triton … miniconda/ with the path to your miniconda package)

We require the development version of yt. Download and extract the yt.tar
$ cd yt_analysis-yt-**
$ python setup.py develop - -prefix=/triton/ics/scratch/users/gentf1/miniconda/
For yt matplotlib may need to be updated
$ conda install matplotlib
$ conda install wxPython

Navigate to where you would like to install the pysac package.
$ git clone https://github.com/fredgent/pysac.git
(or the particular branch/fork of pysac you require)
Without root you will then need to set the path for the pysac installation to match miniconda using the —prefix option
$ python setup.py develop - -prefix=/triton/ics/scratch/users/gentf1/miniconda/
Instead of 'develop', use 'install' if you only want to use pysac and not contribute to its further development.

To be updated: dependencies
sunpy maps needs suds, plotting needs colormath, mayavi requires updated traits

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License