1. Workflow: uv pip
+ requirements.txt
How it works:
- Direct, pip-compatible workflow.
- You manually manage
requirements.txt
.
Typical commands:
bash
# Install a package (does NOT update requirements.txt)
uv pip install requests
# Update requirements.txt to reflect all installed packages (overwrites file!)
uv pip freeze > requirements.txt
# Install all packages from requirements.txt
uv pip install -r requirements.txt
# Sync the environment to match requirements.txt exactly
uv pip sync requirements.txt
Note: No command will automatically update requirements.txt
when you install a package.
You need to update the file yourself, either by editing it manually or by running uv pip freeze
.
2. Workflow: uv add
+ pyproject.toml
(Modern Project Mode)
How it works:
- Modern, reproducible workflow (like Poetry/PDM).
pyproject.toml
anduv.lock
are updated for you.
Typical commands:
bash
# Add a package and auto-update pyproject.toml & uv.lock
uv add requests
# Remove a package and auto-update pyproject.toml & uv.lock
uv remove requests
# Sync the virtual environment with pyproject.toml & uv.lock
uv sync
# Upgrade dependencies to latest allowed by constraints
uv update
uv add
anduv remove
will automatically update bothpyproject.toml
anduv.lock
for you.uv sync
installs exactly the packages and versions specified inuv.lock
.
Summary Table
Workflow | Install Command | Install All | Remove | Update Dependency List? |
---|---|---|---|---|
uv pip + requirements |
uv pip install ... |
uv pip install -r requirements.txt |
โ | โ (manual or uv pip freeze ) |
uv add + pyproject.toml |
uv add ... |
uv sync |
uv remove ... |
โ (automatic) |
Choose uv pip
+ requirements.txt for legacy/simple projects.
Choose uv add
+ pyproject.toml for modern, reproducible Python project management.