What is Python?

Python is a widely used high-level general purpose, interpreted, extensible programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming with dynamic typing and dynamic binding. It supports modules and packages, which encourages program modularity and code reuse. Python is ideal for writing higher-level parts of large-scale scientific applications and driving simulations in parallel architecture like clusters of PC’s or SMP’s.

Using Python

To use non-default Python version, please use the following commands or refer to the sample SLURM scripts at /share1/python/sample/ :

System Command
HPC2021 module load python/[version]

If you invoke python without loading it via module/script first, you will get the default system python.
* Python 2.7 has been end of support since January 2020. We suggest user porting your codes to Python 3.x.

Python packages available in HPC clusters

Package Description
pip python package installer
ipython high performance tools for parallel computing
numpy fundamental package for numerical computation
scipy fundamental library for scientific computing
matplotlib 2D plotting library
biopython tools for biological computation
sympy library for symbolic mathematics
Cython C extensions for python
mpi4py supports the full implementation of MPI standard
multiprocessing supports process-based “threading” on multicore machine

There are many installed packages do not list in the table. You can get the up-to-date installed package information with commands:

– To list installed packages: pip list

– To list outdated packages and show the latest version available: pip list --outdated

– To show details of an installed packages: pip show PackageName

Install Python packages locally in home directory

In some cases, you may want to install some python packages locally. To install add-on package under your home directory, you can:

  1. Install python package by command:
    • Python 3.x: pip3 install --user PackageName
  2. You can then find the python package installed under directory $HOME/lib/pythonx.y/site-packages/ or $HOME/.local/lib/pythonx.y/site-packages/. The exact path can be obtained by command:
    • Python 3.x: python3 -m site --user-site
  3. Upgrade python package by command:
    • Python 3.x: pip3 install --user --upgrade PackageName

Please note that Anaconda is also available as modules in the HPC system. User who want to manage your own python environment/packages is recommended to use Anaconda.

Should you have any problems or issues in the package installation, please contact the system administrator for assistance.

Additional Information

Python official website: www.python.org
Python Documentation: Python 2.x, Python 3.x
Getting Started with Python
Parallel Processing in Python