Installing Virtual Environments for Python with UV

An animated gif of the installation process of uv on Mac OS

What is uv?

uv is a blazingly fast all in one Python management tool. uv is written in Rust and offers:

  • Written in Rust speed efficiency 10x to 100x speedup.
  • Replaces pip, pip-tools, pipx, venv, pyenv and pipx with just one binary.
  • No dependencies uv is a compiled binary not needing any previous Python installation to run.
  • Can run Python scripts or CLI based apps in temporary yet isolated environments with the use of uvx.

Why Use UV for Python management

Very simply uv is a modern tool that dramatically speeds up your workflow. It also helps manage dependencies and keeps your projects organised and separated.

Key Steps

We will setup uv so each project is a version of Python with its own dependency tree. The code for this is shown below.

bash
# Create your project dir
mkdir dsh
cd dsh
# install desired version of Python
uv venv --python 3.11
# activate the virtual environment
source .venv/bin/activate
# test using correct py version
python --version
which python

note: I should have mentioned I used brew to install and manage uv.