uv
An extremely fast Python package and project manager written in Rust.
uv requires an environment module
In order to use uv, you must first load the appropriate environment module:
module load python-uv
uv is a package and project manager for Python, written in Rust. It is designed to be extremely fast and efficient, with a focus on performance and ease of use. It is a drop-in replacement for pip and venv, and can be used to manage Python packages and projects in a similar way.
Using uv on the HPC#
To get started with uv on the HPC, follow the setup instructions below to load the necessary modules and prepare your environment.
First, before using uv, clear any existing environments:
Or as a single command to set up your environment:
Creating a Project with uv#
You can create a new Python project using the uv init command:
Alternatively, you can initialize a project in the working directory:
uv will create the following files:
The `main.py file contains a simple "Hello world" program. Try it out with uv run:
Creating and Activating a Virtual Environment#
You can use uv to create a virtual environment just like with venv:
To deactivate your environment:
Using Python with uv#
Once your environment is activated, you can install packages using uv’s pip interface:
Specifying Python Versions with uv#
You can create virtual environments with specific Python versions using the --python flag.
If a specific Python version is not specified, uv will use the default Python version available in the environment:
To specify a Python version, you can use the --python option. For example, to create a virtual environment with Python 3.13:
Note
While uv can be used with beta versions of Python, this is not recommended, as many community-contributed modules may not function correctly until an official Python release is available.
Using uv with OOD Jupyter Notebooks#
To use uv within Jupyter Notebooks on Open OnDemand (OOD) you must select the proper Python version and type of environment when launching your notebook.
When filling out the job submission form for your Jupyter Notebook, select the following options:
- Python version (required): "python-uv/latest"
- Type of Environment Jupyter is installed in: "UV Virtual Environment" or "UV Project"
or
