Introduction #
Python has become one of the most widely used tools for development, data analysis, and automation in recent years. However, with growing popularity comes increasing demands for performance, security, and reproducibility. Classic tools like pip
, venv
, or pip-tools
have their merits, but they are increasingly reaching their limits, especially in large projects or complex dependency management scenarios.
This is where uv
comes into play: a new tool that combines speed, simplicity, and modern package management. Developed as a replacement and evolution of existing solutions, it brings fresh air to everyday Python work. It combines virtual environments, package management, and lockfile management in a single, performant tool.
A central goal of uv is to make everyday workflows faster and more consistent. While a classic pip install -r requirements.txt
often takes several seconds (or minutes), uv promises installations and updates in fractions of that time. It also places great emphasis on deterministic builds and easy integration into CI/CD pipelines.
Furthermore, uv simplifies onboarding for new developers into existing projects. Instead of laboriously manually installing virtual environments and dependencies, a simple uv sync
is enough to get a project running. Especially in teams, this significantly reduces friction.
Installation #
Installing uv is remarkably simple. On Linux and macOS, simply run:
curl -LsSf https://astral.sh/uv/install.sh | sh
On Windows, uv can be installed via powershell
:
irm https://astral.sh/uv/install.ps1 | iex
After installation, the uv
command is available in the terminal. We can verify that the installation was successful with uv --version
.
Getting Started #
A typical workflow with uv looks like this:
# Start a new project
uv init my-project
cd my-project
# Add dependencies
uv add requests
# Run script
uv run python main.py
Here, uv automatically handles creating a virtual environment, managing dependencies, and creating a uv.lock
file. This file is the cornerstone for reproducible builds.
graph TD A[Project start with uv init] --> B[uv add] B --> C[Generate uv.lock] C --> D[uv sync] D --> E[uv run: Execute scripts]
Use Cases #
uv is not just another “nice to have” tool, but a genuine alternative to established tools. Let’s look at three concrete scenarios where uv can replace classic tools:
1. Replacement for pip
& requirements.txt
#
Previously:
pip install -r requirements.txt
With uv:
uv sync
Advantages:
- Faster through caching and parallel downloads
- Lockfile ensures reproducible installations
- No manual maintenance of a
requirements.txt
file needed
2. Replacement for venv
#
Previously:
python -m venv .venv
source .venv/bin/activate
python app.py
With uv:
uv venv
uv run python app.py
# or optionally
uv venv --python 3.13
Advantages:
- Automatic creation and activation of the environment
- No manual handling required anymore
- Different Python versions available through a single flag
3. Replacement for pip-tools
#
Previously:
pip-compile requirements.in
pip install -r requirements.txt
With uv:
uv add fastapi uvicorn
uv automatically generates a uv.lock
file that pursues the same goal as pip-compile
, but faster and without additional tools.
Advanced Features of uv #
Usage in CI/CD Pipelines #
Thanks to the deterministic lockfile, uv is ideal for use in automated pipelines. A uv sync
ensures that exactly the same packages are installed in all environments.
# Example for GitHub Actions
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync
- name: Run tests
run: uv run pytest
Global Package Management #
uv allows not only project-specific environments but can also manage global packages. This is practical for tools that should be available system-wide, such as black
or pre-commit
.
uv tool install black
uv tool run black --version
Performance Comparison #
A major advantage of uv is its speed. Benchmarks show significant differences:
graph LR A[pip install requests] -->|~6 seconds| B[Installation completed] C[uv add requests] -->|~0.8 seconds| D[Installation completed]
In tests, uv was able to reduce installation time by a factor of 5–10. Especially in large projects, this adds up to significant time savings. For example, you can improve your CI/CD pipeline times without major changes.
Visualizing Dependencies #
uv offers the ability to clearly display dependencies:
$ uv tree
Resolved 11 packages in 0.64ms
uvtestproject v0.1.0
├── django v5.1.2 (latest: v5.1.3)
├── mypy v1.13.0 (group: dev)
├── ruff v0.7.3 (group: dev)
└── gunicorn v23.0.0 (group: prod)
This provides a structured overview, similar to npm ls
in the JavaScript ecosystem.
Practical Examples #
Starting a FastAPI Project #
uv init web-api
cd web-api
uv add fastapi uvicorn
uv run uvicorn main:app --reload
Data Science Workflow #
uv init data-project
cd data-project
uv add numpy pandas matplotlib jupyter
uv run jupyter notebook
Preparing Deployment #
In CI/CD environments:
uv sync --frozen
uv run pytest
The --frozen
flag ensures that exactly the versions defined in the lockfile are used.
Conclusion #
With uv, we have a tool at hand that simplifies and accelerates many well-known processes. It combines the functions of pip
, venv
, and pip-tools
in a modern, performant solution. Particularly exciting is the focus on speed and reproducibility – two factors that are becoming increasingly important in modern software development.
uv is therefore not just a tool for enthusiasts, but a serious candidate for the new standard in the Python ecosystem. It lowers barriers to entry for new developers, increases productivity in teams, and reduces sources of error in deployments.
We can view uv as the next step in the evolution of Python development. Anyone starting a new project today should seriously consider using uv as their standard tool.
If you have questions or comments about the article, feel free to contact me through the channels mentioned below.
Further Reading: