Getting Started with Python Environments

Python virtual environments are useful to install Python packages that are either unavailable as modules on Nova, or for which a different package version is necessary.  To create a Python virtual environment from the cluster terminal:

  1. Load the Python module:
    module load python
  2. Create the virtual environment:
    python3 -m venv <EnvName>
    Where <EnvName> is the name of the new virtual environment.  The virtual environment files will be stored in the current working directory.
  3. Activate the virtual environment:
    source <EnvName>/bin/activate
    Where <EnvName> is the name of the virtual environment.  If the current working directory is not the directory where the environment is stored, you will need to provide the full path to the environment.
  4. To install a package in the environment:
    python3 -m pip --no-cache-dir install <PackageName>
    Where <PackageName> is the name of the package to be installed.
  5. To deactivate the environment:
    deactivate