---
tags:
  - Free
catalog:
  name: Python
  description: The programming language and its modules at CSC
  license_type: Free
  disciplines:
    - Mathematics and Statistics
  available_on:
    - Roihu
    - Puhti
    - Mahti
---

# Python

[Python](https://www.python.org/) is a general-purpose high-level
programming language that is widely used for scientific computing.
For instructions on using Python effectively on CSC supercomputers,
please see our
[Python usage guide](../support/tutorials/python-usage-guide.md).

## Available

* Roihu: 3.x. versions
* Puhti: 3.x versions
* Mahti: 3.x versions

## License

Python packages are usually licensed under various free and open source (FOSS)
licenses. Python itself is licensed under the
[PSF License](https://docs.python.org/3/license.html), which is also open source.

## Usage

Our
[Python usage guide](../support/tutorials/python-usage-guide.md)
contains instructions for installing packages,
using different development environments and doing parallel processing
with Python.

It is generally recommended to use one of
[pre-installed Python environments](./python.md#pre-installed-python-environments)
for computing,
since these already contain the essential libraries for most uses.
If for some reason one wishes to use Python without loading an environment
module, a
basic
[system Python](python.md#system-python)
is also available.

### System Python

If using a pre-installed environment is not suitable,
the basic system Python 3.9 in Roihu can be launched with:

```bash
python
```

In Puhti and Mahti, Python 3.9 can be launched with:

```bash
python3.9
```

Note that the  the default version launched by `python3` (3.6.8) in Puhti and Mahti has [reached end-of-life](https://devguide.python.org/versions/) and it is strongly advised to explicitly launch Python version 3.9 as above.

### Pre-installed Python environments

Roihu, Puhti and Mahti have several pre-installed
[environment modules](../computing/modules.md) containing
Python environments made for different science areas.

In Roihu: 

| Module name | Purpose | Roihu-CPU/Roihu-GPU |
|-|-|-|
| [python-geo](python-geo.md) | geoinformatics | CPU |
| [python-data](python-data.md) | data analysis and ML utilities | CPU/GPU |
| [python-pytorch](pytorch.md) | PyTorch ML framework | GPU |
| [python-vllm](vllm.md) | LLM inference | GPU |
| [python-tensorflow](tensorflow.md) | Tensorflow ML framework | GPU |
| [python-jax](jax.md) | JAX ML framework | GPU |

In Puhti and Mahti:

| Module name | Purpose |
|-|-|
| [biopythontools](biopython.md) | bioinformatics |
| [geoconda](geoconda.md) | geoinformatics |
| [jax](jax.md) | JAX ML framework |
| [python-data](python-data.md) | data analysis and ML utilities |
| [pytorch](pytorch.md) | PyTorch ML framework |
| [qiskit](qiskit.md) | quantum computing |
| [tensorflow](tensorflow.md) | TensorFlow ML framework |

To use any of the above environments, simply load the corresponding module
using the `module load` command.

```bash
module load <MODULE_NAME>  # e.g. module load python-data
```

To see the Python libraries included in a module, you can run the following
line. The `-s` option
[excludes packages installed by the user](https://docs.python.org/3/using/cmdline.html#cmdoption-s).

```bash
python3 -sm pip list
```

Typically, after activating a Python-based module, the `python3` command points
to a version of Python that is newer than the default system Python and has a
wider set of available packages. You can always check the Python version
with the command `python3 --version`, and the full path of the command with
`which python3` (to see if you are using the system Python or one from the
modules listed above).

!!! info ""

    Note that most of the pre-installed Python environment modules are
    self-contained and mutually exclusive environments, so it does not
    make sense to for example load both python-data and python-pytorch
    modules. The module loaded last will be the only active one, and
    the module load command will warn about this, for example in Roihu:

    ```
    Lmod is automatically replacing "python-data/3.12-31.03" with "python-pytorch/2.10".
    ```


### Custom Python environments

While the pre-installed Python environments suffice for many applications,
projects often involve tasks which require additional libraries.
The following options are available in this case:

* [Installing Python packages to existing modules](../support/tutorials/python-usage-guide.md#installing-python-packages-to-existing-modules)
* [Creating your own Python environments](../support/tutorials/python-usage-guide.md#creating-your-own-python-environments)

## References

* [Python Software Foundation](https://www.python.org/psf-landing/)

## More information

* [Python documentation](https://docs.python.org/3/)
* [The Python Package Index](https://pypi.org/)
