Skip to content

Python

Using Python virtual environments with venv or conda

For Python specifically, you can set up a virtual environment, which acts similarly to a personal module but for using Python packages. In these virtual environments, you can install whichever Python packages you want using pip, and the result exists as a directory that you can load into sessions. See the following example for how you can create the virtual environment myenv:

$ module load python # (1)!
$ python3 -m venv myenv
$ source myenv/bin/activate
$ pip install <my-python-package>
  1. This will load the cluster default python version. If you need a specific version, you can instead use module load python/3.12.4.

Once the virtual environment is created, you can now run the source command to load it into a new session and use your Python packages such as NumPy or SciPy.

$ module load miniconda3
$ conda create --name <my-env>
$ conda init bash
$ conda activate <my-env>
$ conda install <my-python-package>

conda env