Skip to content

uv

An extremely fast Python package and project manager written in Rust.


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:

$ conda deactivate        # Deactivate any active Conda environments
Then, load the required modules:
$ module load webproxy    # Enables internet access for downloading packages on compute nodes (e.g. when running in OOD)
$ module load python-uv   # Loads the uv-based Python environment

Or as a single command to set up your environment:

$  ml purge && conda deactivate && ml webproxy python-uv

Creating and Activating a Virtual Environment#

You can use uv to create a virtual environment just like with venv:

$ uv venv ~/myenv               # Create virtual environment in ~/myenv
$ source ~/myenv/bin/activate   # Activate the environment

To deactivate your environment:

(myenv) $ deactivate

Using Python with uv#

Once your environment is activated, you can install packages using uv’s pip interface:

(myenv) $ uv pip install flask   # Installs Flask

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:

1
2
3
4
5
6
$ uv venv ~/myenv
$ source ~/myenv/bin/activate
(myenv) $ which python
~/myenv/bin/python
(myenv) $ python --version
Python 3.13.3

To specify a Python version, you can use the --python option. For example, to create a virtual environment with Python 3.13:

1
2
3
4
$ uv venv ~/myenv --python 3.12
$ source ~/myenv/bin/activate
(myenv) $ python --version
Python 3.12.10

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.