Creating and Using Python Environments on Clipper

Summary

How to create and access different types of Python environments on Clipper.

Body

Overview

Python environments are isolated installations that allow users to manage project-specific dependencies without affecting other users or projects on the system. They provide several key benefits:

  • Isolation: Each environment maintains its own separate set of Python packages and dependencies
  • Version Control: Different projects can use different versions of Python or packages without conflicts
  • Reproducibility: Environments can be recreated consistently across different systems
  • Security: Changes in one environment don't affect other users or the system Python installation

On Clipper, users have two main options for managing Python environments:

  1. Conda Environments: A comprehensive environment management system that can handle Python and non-Python dependencies
  2. Virtual Environments: A lightweight, built-in Python tool focused specifically on Python package management; Python virtual environments are the recommended way to manage Python projects on the Clipper HPC cluster.

Choose Your Environment Type

Conda Environments
Python Virtual Environments

Creating and Using Python Virtual Environments on Clipper

Python virtual environments are the recommended way to manage Python projects on the Clipper HPC cluster.

Virtual environments are isolated Python installations that allow for easy management of project-specific dependencies. Virtual environments allow individuals to create a tailored environment without affecting the global Python installation available to all Clipper users.

This section describes how to create a Python virtual environment on Clipper.

 

Creating Virtual Environments

Private virtual environments can be stored either in your /mnt/home folder or project space allocated on /mnt/projects.

Will this virtual environment be used for a class or a large number of users? Contact Academic Research Computing support to establish a globally-available Python virtual environment.

To create a virtual environment, use the built-in venv Python module. This example installs a virtual environment into a hypothetical /mnt/home/hpcuser1 directory.

Navigate to the directory in which you wish to create the virtual environment:

[hpcuser1@clipper ~]$ cd /mnt/home/hpcuser1

Create the virtual environment with the venv module:

[hpcuser1@clipper ~]$ python3 -m venv myproject

This will create a directory named myproject containing the virtual environment's files inside of /home/hpcuser1.

 

Using Virtual Environments

Activation and Deactivation

Virtual environments must be activated. Activating a virtual environment makes the isolated Python interpreter and packages available in your shell.

To activate the earlier-created environment, run:

[hpcuser1@clipper ~]$ source myproject/bin/activate

Once activated, your shell prompt will change to indicate you are in the virtual environment:

(myproject) [hpcuser1@clipper ~]$

To deactivate the environment and return to the system default Python environment, type:

deactivate

Installing Packages

Use the pip package manager to install packages inside the virtual environment. Once you have activated the environment, run:

python3 -m pip install <package>

For example, to install the BeautifulSoup library, run:

python3 -m pip install beautifulsoup4

pip will handle the installation of Beautiful Soup and all necessary dependencies automatically.

Packages can also be removed from the virtual environment:

python3 -m pip uninstall <package>

 

Python Version Note

Clipper's default Python version is that of its underlying operating system, Red Hat Enterprise Linux 9. As of May 2024, the Python version available on Clipper is 3.9.21.

Additionally, Python 3.10.14, 3.11.9, 3.12.5 and 3.13.0 are available through the Lmod modules system.

Should you need a different version of Python, please contact Academic Research Computing support with your request and justification.

Best Practices

  1. Project Isolation: Create separate environments for each project to prevent dependency conflicts
  2. Version Control: If using Git, add environment directories to .gitignore
  3. Documentation: Maintain a list of required packages (requirements.txt for virtual environments or environment.yml for Conda)
  4. Regular Updates: Periodically update packages while testing for compatibility

System Information

As of January 2026:

  • Default Python version: 3.9.23 (RHEL 9)
  • Python 3.10.19, 3.11.14 and 3.12.12, 3.13.8, 3.14.0 available via Lmod modules
  • Miniconda3 version: 25.5.1
  • Miniforge3 version 25.3.0

For requests regarding different Python or Conda versions, contact Academic Research Computing support with your justification.

Details

Details

Article ID: 21850
Created
Thu 10/24/24 1:44 PM
Modified
Fri 12/19/25 9:04 AM