Knowledge Base

Python on the Academic Computing Cluster

The recommended python distribution on  the Reading Academic Computing Cluster (RACC) is Anaconda Individual Edition. It is installed centrally with the standard set op packages, and can be accessed with the ‘module‘ command. Anaconda provides a large collection of scientific packages, and not only python based ones. Those packages can be installed by users in their home directories using conda user environments.

Note that the Python environment packaged with the operating system is also installed and this is the environment you get when you type ‘python’ with no python module loaded.

Python 3 is fundamentally different from, and not compatible with Python 2. Some Python 2.7 programs might still be in use. Previously the modules running Python 2.7 were grouped under ‘python2.7/…’. and the modules loading Python 3 environments are grouped under ‘python3/…’. The new version of Anaconda is now installed under module name anaconda, the base environment is with python 3.8, and we recommend the users requiring python 2.7 should just create user environments with this old version of python.  Check with the command ‘module avail ‘ for the full list of options on the RACC.

 

Quick start with Anaconda

The easiest way to start using Anaconda is with it’s GUI called Anaconda Navigator. To launch it we need to load the ‘module‘ :

module load anaconda

Then we can use anaconda from the command line or we start the GUI by typing:

anaconda-navigator

From Anaconda Navigator you can launch various GUI application, and you can install more application and packages in your personal user environments.  For more instruction, please refer to the Anaconda documentation.

 

Notes about user environments

Your user environments will be located in the directory .conda in your home directory. If you decide to create an environment that contains all the default Anaconda packages, by installing the package ‘anaconda’, it will take around 3GB of space, and even more space will be used when you install further packages.  It is not possible to set this up in a different location. Home directories can easily fill up, causing various computing issues, so please be mindful of this when you choose to install your own Python environments.

When you start you will see the base environment, this is where you land when you load the module, and other centrally managed environments (if any are provided in the future). If you used Anaconda before, you might also see your personal environments you created in the past, possibly with some older versions of anaconda.

 

Managing user environments from the command line

Typical installation of Anaconda adds some lines in your .bashrc file, such that an init script is sourced and some shell function are define. We do not fully perform this initialisation when you load a module, the function are not defined then. This is why the following commands might be slightly different than in the instructions provided by Anaconda (e.g. we use ‘source activate’, not ‘conda activate’). After loading module anaconda you are in the ‘base’ environment, although we do not show this in the shell prompt.

First you’ll need to load the anaconda module, the most up to date version is available with the command:

module load anaconda

Note that you can specify the Python version you want at the time of creating your environment. The instructions are the same whether you want Python 2.7 or 3.5, just specify your preferred version accordingly in the ‘conda create’ command below.

You can now create your own environment (called ‘myenv’ in our example here) with the following command:

conda create -n myenv python=X.X

Substitute ‘X.X’ with the Python version that you want to install in your environment in the command above, e.g. 2.7 or 3.5. If you don’t have a preferred python version, you can remove the python=X.X part.

You will only need to run the above command once. It creates an empty environment with the name ‘myenv’. Once finished, you can call your own environment from the terminal shell with:

source activate myenv

Note that the anaconda module has to be loaded in order for this to work. When your environment is successfully loaded, the terminal prompt is preceded by ‘(myenv)’, e.g.:

(myenv2) [dk913223@racc-login-0-1 ~]$

Now you can install your own packages in your environment with:

conda install packagename

Note that in addition to the default package channel, other channels (package repositories), e.g. widely used conda-forge, are available. Often you can quickly find how to install software using conda, e.g. when you don’t know the exact conda package name, or what channel to use, form Google.   If the package you require is not found via the ‘conda’ command, you can also try using ‘pip’:

pip install packagename

If both of the above options can’t find what you’re looking for, it’s still possible to install your desired package by downloading it directly from the developer and following their installation instructions whilst the your environment is activated.

 

User Installation in Python Canopy 2.1 (not recommended, deprecated)

Before you begin, please note that at least 2GB of free space are required in your home directory for the Canopy Python user installation. It is not possible to install this in a different location. Home directories can easily fill up, causing various computing issues, so please be mindful of this when you choose to install your own Python environment.

The following command installs your personal Python environment from the Canopy 2.1.8 distribution. You will only need to run this once and afterwards your personal environment will be automatically called when you load the ‘canopy2-userenv’ module.

/share/apps/python/python2.7/canopy-2.1.8-userenv/canopy

The installation will take quite a while and end with displaying the Canopy GUI. From here, you can install additional packages in the ‘Package Manager’. In order to use this feature, you’ll need to register with Enthought.

From now on your own Python user environment can be simply loaded with:

module load canopy2-userenv

If you don’t want to use the Canopy package manager to install packages, you can also use the native ‘edm’ command instead.

edm install packagename

If the package you require is not found via the ‘edm’ command, you can also try using ‘pip’:

pip install packagename

If both of the above options can’t find what you’re looking for, it’s still possible to install your desired package by downloading it directly from the developer and following their installation instructions whilst the canopy2-userenv module is loaded.