Using Python on Faculty of Environment Linux Systems


An overview of the versions of Python available on Faculty of Environment Linux systems, including Python2, Python3, Canopy and Spyder.

 

Summary

To use Python version 2, run:

module load python2 python-libs

To use Python version 3:

module load python3 python-libs

 

Available Versions Of Python

All Faculty Linux systems will have a version of python available at /usr/bin/python. At present, this will be Python version 2, though there may also be a system version of Python 3 available at /usr/bin/python3.

The system versions of Python will generally be older versions, with a limited set of libraries available, and may be suitable for some purposes, but we generally recommend using the Enthought Canopy Python environment which is available on the faculty Linux systems.

 

Canopy Python Environment

We having been using Canopy and its predecessors for a number of years in the Faculty, with great success.

The Canopy Python Environment provides a recent version of Python (version 2 or 3), and many common / popular libraries (Matplotlib, Numpy, Scipy (optimised with Intel MKL), etc.).

 

Python2

The Canopy Python2 Environment can be accessed via the Environment Modules by running:

module load python2

This will set all of the required variables to use the Canopy Python Environment (Python Version 2).

You can verify which version of Python is your default with:

which python

and:

python -V

 

Python3

The Canopy Python3 Environment can be accessed via the Environment Modules by running:

module load python3

This will set all of the required variables to use the Canopy Python Environment (Python Version 3).

You can verify which version of Python is your default with:

which python

and:

python -V

 

Canopy Graphical Development Environment

The Canopy Python Environment also provides a graphical editor / development environment which can be accessed with:

canopy

Canopy Editor

The Canopy editor for Python2 and Python3 can also be launched from the links in the desktop applications menu, in the 'Environment' section.

 

Additional Python Libraries

Many additional Python libraries are available via the python-libs module, which has a dependency on a Python module being loaded.

To load Python2 and the python-libs:

module load python2 python-libs

To load Python3 and the python-libs:

module load python3 python-libs

The current content of the python-libs (including version numbers) can be viewed with:

module help python-libs

The content includes the popular SciTools Iris and ObsPy libraries as well as many others.

Many of the libraries are available for both Python2 and Python3, but availability and versions may differ slightly.

 

Spyder Graphical Development Environment

Spyder is a powerful interactive graphical development environment, for working with Python.

Spyder IDE

spyder is included in the python-libs.

For Python2, to load the Python environment, the additional Python libraries, and then launch spyder:

 

module load python2 python-libs
spyder

For Python3, to load the Python environment, the additional Python libraries, and then launch spyder:

 

module load python3 python-libs
spyder

Spyder for Python2 and Python3 can also be launched from the links in the desktop applications menu, in the 'Environment' section.

 

Installing Packages

If you would like an additional library to be added to the python-libs on the systems, please contact IT via https://it.leeds.ac.uk (including a request that the ticket is assigned to the 'Client Linux Team').

If you would like to install your own personal libraries, there are many different ways in which this can be done. The simplest ways are to update the PYTHONPATH environment variable to include a directory which contains your personal Python libraries. For example, if you had some libraries in the directorg ${HOME}/python/lib, you could, in csh:

setenv PYTHONPATH "${HOME}/python/lib:${PYTHONPATH}"

or, in bash:

export PYTHONPATH="${HOME}/python/lib:${PYTHONPATH}"

The pip command can also be used to install packages in your home directory:

pip install --user libraryname

This would install the libraryname within the directory ${HOME}/.local, which would then be available for use.

More details can be found with:

pip help

and:

pip help install

 

Installing Your Own Python Environment

You can, of course, install and manage your own Python environment within your own file space.

The most popular Python Environment these days is the Anaconda Python Environment, which is available for Linux, Windows and Apple Operating Systems, and both Python2 and Python3 variants are available.

The Anaconda Python Environment can use a fair amount of disk space, so you may wish to look at Miniconda as a more compact alternative.

 

Useful Links

There is a huge amount of Python documentation available via the internet. These pages have been created by people within the University of Leeds: