Skip to content

Python

Description

python website

Python is a scripting programming language that lets you work more quickly and integrate your systems more effectively. You can learn to use Python and see almost immediate gains in productivity and lower maintenance costs. This is a full-featured python distribution with hundreds of modules for developing and running Python-based research applications installed on request. Because of that module versions will change without notice and incompatibilities may arise. Open a support ticket when you encounter an error with any python module in this environment. Modules system sets up the following environment variables for this module:

Environment Modules

Run module spider python to find out what environment modules are available for this application.

Environment Variables

  • HPC_PYTHON_DIR - installation directory
  • HPC_PYTHON_BIN - executable directory
  • HPC_PYTHON_LIB - library directory
  • HPC_PYTHON_INC - includes directory (with python3.10m)

Additional Usage Information

  • After the appropriate environment module is loaded - type "python" at the command line to open an interactive session.
  • To run a python script type python scriptname.py. If the correct "shebang" line is used at the top of the script E.g.
#!/usr/bin/env python

then the script can be run directly as scriptname.py if it's in the executable path or as ./scriptname.py if it's in the current directory. The same rules apply to using a python script in a batch job script.

You can request installation of additional modules by submitting a request ticket in the Support System. The support request tickets can be used for requesting software installation, finding a solution to a particular problem, or just asking a question.

See also: Managing Python environments and Jupyter kernels

Matplotlib Backend

If you are trying to use matplotlib and get an error similar to either of the following:

ImportError: No module named _tkinter
This application failed to start because no Qt platform plugin could be initialized.
then you should try the following before importing pyplot from matplotlib:
import matplotlib
matplotlib.use('Agg')

Output Buffering

your job starts, but doesn't appear to produce output from 'print' statements in the job log for a long time, but you want to see that output immediately then turn off output buffering. You can either add a flush=True argument to the print calls you are interested in or run the script with srun --unbuffered python SCRIPT.py

Available modules

  • To see all installed modules names load the environment module and run pip list or python -c "help('modules')" command before submitting a request for a new module installation.
  • To install their own packages, users can load any module that has python within and run pip install "package".
  • Users can define an install path by running: pip install --install-option="--prefix=/some/path/" package_name.

Categories

programming, language