UV – Ultra Fast Python Package Manager
🧾 Overview
UV is an extremely fast Python project and package manager written in Rust.
- Manages dependencies, virtual environments, and Python versions.
- Can replace
pip
,pipx
,pip-tools
, orpoetry
. - Blazing fast due to being built in Rust.
⚙️ Installation
On macOS (via Homebrew)
brew install uv
Using pip
pip install uv
Enable shell auto-completion (e.g., for zsh)
eval "$(uv generate-shell-completion zsh)"
Example:
uv c[TAB]
will autocomplete the command.
🚀 Setting Up a Project
Initialize a project
uv init --app my_app_name # Default type (application)
uv init --package my_package_name
uv init --lib my_lib_name
Run a script and create a virtual environment
uv run hello.py
This will create a virtual environment automatically.
Add or remove dependencies
uv add pandas
uv remove pandas
Sync environment and workspace
uv sync
Upgrade a specific package
uv lock --upgrade pandas
Show dependency tree
uv tree
📦 Dependency Management (Workspaces)
UV supports workspaces, allowing you to manage multiple virtual environments in a single directory.
- Running
uv init
inside an existing UV project creates a sub-project with its own virtual environment:
uv init new_project
uv add pandas
- To create a fully isolated project (not in the workspace):
uv init another_project --no-workspace
🛠️ UV Tools
Run a tool (e.g., ruff
)
uv tool run ruff check
Check where tools are installed
uv tool dir
Install a tool
uv tool install ruff
🐍 Python Version Management
List available Python versions
uv python list
Install a specific version
uv python install 3.12.0
Set Python version for a virtual environment
uv venv --python 3.12.0
Top comments (0)