Modern Python Workflow with UV
Python packaging has historically been a fragmented mess between pip, venv, and pyenv. Developers often spend more time managing environments than writing code, and this is where uv a fast Python package comes to help.
What is uv?
Developed by Astral (the creators of Ruff), uv is a single executable designed to replace your entire Python toolchain that acts as:
- Package Manager (replacing
pip) - Environment Manager (replacing
venv) - Python Version Manager (replacing
pyenv) - Tool Runner (replacing
pipx)
Why use it?
-
Unmatched Speed It is 10–100x faster than
pip. On a cold cache, it installs packages in milliseconds. On a warm cache, it is virtually instantaneous because it leverages a global module cache and hardlinks. -
Zero Dependencies Since it is written in Rust,
uvis a standalone binary. You don’t even need Python installed to installuv, it can install Python for you. -
Universal Lockfiles It generates a
uv.lockfile that ensures your environment is identical across your local machine, CI/CD, and production servers (AWS). -
Modern Defaults It supports
pyproject.tomlnatively and handles dependency resolution without "backtracking" hangs common in older tools.
How it works
1. Project Initialization
Start a new project with a standard structure:
uv init my-project
cd my-project
2. Managing Dependencies
Adding a package creates a virtual environment (.venv) and updates lockfile:
uv add fastapi pydantic
3. Running Scripts
You can run a script in a temporary environment without "activating" anything:
uv run main.py
4. Managing Python Versions
Need a specific version for a training job?
uv python install 3.12
uv python pin 3.12
The Verdict
uv replaces the frustration of broken environments with a single, fast tool that just works. It takes the guesswork out of Python project management letting you focus on building your features instead of fixing your dependencies.