You are here:

Python

Python is an interpreted language which is easy to learn and very apt for e.g. proto-typing.

The default (system) version of Python on our CentOS 7 clusters is /usr/bin/python:

[unid@cluster]$ python
Python 2.7.5 (default, Sep 15 2016, 22:37:39)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

This Python version is older, may not include packages that one may need, and the included packages may not have optimal performance. For this reason the CHPC supports the following versions of Python actively on our CentOS 7 systems:

  • Python 2.7.11  (Python 2)
  • Python 3.5.2  (Python 3)

If you plan to use Python for scripting/development, we recommend you to use one of those 2 versions because

they also contain quite a few external modules to perform scientific computing (please see below).

Both of the above versions do support OpenMP threading. The OpenMP threading has been switched off. To invoke the threading you need

to set env. variable OMP_NUM_THREADS to x ( x being a number <= #cores on the machine)

export OMP_NUM_THREADS=x  # Bash
setenv OMP_NUM_THREADS x # Tcsh

In order to use Python 2.7.11 on our clusters/desktop, you need to invoke the following command:

module load python/2.7.11

 If you would like to use Python 3.5.2, you need to execute the following command:

module load python/3.5.2

We have also installed the Intel Distribution for Python, however, note that we do not support any additional packages other that come with the Distribution. To use the Intel Distribution for Python, for either Python 2 or Python 3, run:

module load intelpy/2.7.12
module load intelpy/3.5.2

Integrated development environment

There is a number of IDEs for Python development, some of which are marginally stable. We recommend using free PyCharm Community. As it features automatic updates, we require users to download and install PyCharm in their home directory. As IDE requires graphical connection to our servers, one needs to run FastX2 or other means of X window connection in order to use PyCharm.

After installation of the PyCharm, one can add the PyCharm bin directory to the PATH:

setenv PATH "$HOME/pycharm/bin:$PATH" - for tcsh
export PATH=$HOME/pycharm/bin:$PATH" - for bash

or, even better, create custom module, e.g. create a file $HOME/mymodules/pycharm/version.lua:

-- -*- lua -*-
help(
[[
This module loads the env. variables
for PyCharm (v. 2016.1.4)
]])
whatis("Name: PyCharm ")
whatis("Version: 2016.1.4 ")
whatis("Category: IDE ")
whatis("Keywords: IDE, Python ")
whatis("Installed on 06/03/2016")
prepend_path("PATH","/uufs/chpc.utah.edu/common/home/UNID/pycharm/2016.1.4/bin")

and then adding the modules directory to as a custom module and load the module and run PyCharm:

module use $HOME/mymodules
module load pycharm
pycharm.sh

Installed packages

Each of the aforementioned python distribution has an array of packages installed. You can list all the currently installed packages, by typing:

  • python 2.7.11:
    module load python/2.7.11
    pip list
  • python 3.5.2:
    module load python/3.5.2
    pip3 list

Certain packages do not belong in the CHPC distribution because they are e.g. cluster specific. The installation of a derived Python Distribution using the Python Virtual Environment allows you to use those packages (e.g. NumPy, SciPy, etc.) that are installed within the general distribution and to install/use specific packages that are only available in the new (derived) environment. For more info, please have a look at our Python Virtual Environment page.

External documentation

Below, you can find the links to the documentation of some important packages.

Last Updated: 3/28/17