Python

Python environment modules | Using the NCAR package library

Multiple versions of Python are available on the Cheyenne and Casper systems. For some older versions, Python packages can be loaded only by using environment modules. For newer versions, Python packages can be loaded only using the NCAR package library.

Both of these methods are described below.


Python environment modules

CISL recommends loading a Python environment module before invoking the python command. Invoking python without loading a module first will start an older system version (Python 2.7.9) that is used mostly for system scripting and other administrative tasks.

To load an environment module that will provide a Python 2 environment for you to use, run:

module load python/2.7.14

Alternatively, you can use Python 3 by running:

module load python/3.6.4

Older versions of both Python 2 and 3 are available using the module system. These older versions use modules to load Python packages (module load numpy, for example), as opposed to the newer method of loading packages that is described below.

 


Using the NCAR package library

After loading the desired Python module (versions ≥ 2.7.14, ≥ 3.6.4), users can load all NCAR-provided Python packages at once by activating the NCAR package library virtual environment. Run the ncar_pylib script to activate the latest version of the package library.

ncar_pylib

This utility can also be used to load older versions of the library, which are listed by the date of creation.

To list all versions of the NCAR package library:

ncar_pylib -l

To list the packages (and version numbers) that are included in a library version:

ncar_pylib -p 20180128

If a package that you want is not available in the current library, you can clone the library as described below and install the package for yourself using pip, or request a custom build by emailing cislhelp@ucar.edu.

 

Creating your own clone of the NCAR package library

Creating a personal clone of the package library in your GLADE space is useful if you want to add or update packages, or develop Python code while using NCAR-provided packages. Simply specify the clone option (-c) to ncar_pylib, select a version of the package library, and choose a destination path for the clone.

ncar_pylib -c 20180128 /glade/work/$USER/personal_clone_name

Then, use the standard virtual environment utility to activate your clone of the package library by sourcing it:

cd /glade/work/$USER/personal_clone_name/bin
source activate.csh (tcsh)
OR
source activate (bash)

You can then install or upgrade packages from the Python Package Index using the pip utility. For example, to install your own copy of the seaborn plotting library, you could run:

pip install seaborn