Python

Python is a programming language.

Although there are several versions of Python currently installed on ALICE and SPECTRE, we recommend using the latest version installed.

Libraries

There are a number of additional Python libraries installed on ALICE and SPECTRE including:

Additional libraries are included with certain modules:

  • HDF5
  • HDF4
  • GEOS
  • Biopython

etc.

If you need other libraries you can install them manually into your own home directory using pip or setup-tools, however we recommend setting up a python virtual environment for your own use.

Anaconda / Conda / Miniconda

If you choose to install one of the *condas, Miniconda is recommended over Anaconda and Conda as it will use less space in your home directory (the default installation location).

When installing Miniconda you will be asked if you want to modify ~/.bashrc - select 'no'. If you select 'yes' you may experience problems accessing HPC using NX.

Instead, add the line suggested by the installer to ~/.bash_profile, eg:

echo source $HOME/miniconda3/etc/profile.d/conda.sh >> $HOME/.bash_profile

Virtual environment

A python virtual environment installs a python environment (and a default set of libraries) into a directory you specify. This makes it simple to use pip or set utils to install your own modules.

  • Load the python module
module load python/gcc/36
  • Create the virtualenv - in this case I am creating a virtual environment in the "my_python" directory within my home directory.
virtualenv --system-site-packages --prompt=$USER-my_python my_python
  • Activate the virtual environment
source $HOME/my_python/bin/activate

On next login, you will only need to repeat the final to load your environment and any libraries you have installed into it.

To install libraries, you can simply run a standard pip command, for example, to install the gi module:

pip install gi

Graphical console

A graphical console based on IPython is available. This provides syntax colouring, tooltips and graphical output. (The normal text-based IPython is also available.)

ipython qtconsole

ipython

If you prefer Python plots to be displayed in separate windows rather than inline, omit the --pylab=inline option of the ipython command.

IPython should not be used on the ALICE login nodes. It should only be used on SPECTRE or via an interactive job on ALICE.

Share this page: