Overview
uv provides a drop-in replacement for commonpip, pip-tools, and virtualenv commands. These commands work directly with virtual environments, offering the speed and functionality of uv to power users and projects not ready to transition from pip.
The
uv pip interface operates at a lower level than uv’s primary project interface. For new projects, consider using projects instead.uv doesn’t rely on or invoke pip. The pip interface is named to highlight its purpose: providing low-level commands matching pip’s interface, separate from uv’s higher-level abstractions.
Creating and using environments
Creating virtual environments
Create a virtual environment likepython -m venv:
.venv directory in the current location.
Activating environments
After creating, activate the environment:Installing and managing packages
Installing packages
Installing from different sources
Editable packages
Install packages in editable mode:Installing from files
Install from various file formats:Installing dependency groups
Install groups frompyproject.toml:
--group flags don’t apply to other sources like -r. For example, uv pip install -r some/path/pyproject.toml --group foo sources foo from ./pyproject.toml, not some/path/pyproject.toml.Uninstalling packages
Locking and syncing environments
Locking requirements
Generate a lockedrequirements.txt:
By default,
uv pip compile prints output to stdout. Use -o / --output-file to write to a file.Compiling with extras
A
--group flag was added to uv pip compile, though pip-tools is considering it. We’ll support whatever syntax they adopt.Upgrading requirements
uv respects existing pinned versions in output files:Syncing environments
Sync environment to exactly match a lockfile:Inspecting environments and packages
List installed packages
Check package information
Working with constraints and overrides
Adding constraints
Constraint files control versions without triggering installation:constraints.txt
constraint-dependencies from workspace root pyproject.toml.
Build constraints
Constrain build-time dependencies:build-constraints.txt
pyproject.toml
Overriding versions
Force specific versions regardless of declared requirements:overrides.txt
Migrating from pip
Common command mappings
Install commands
Install commands
Uninstall commands
Uninstall commands
List and inspect
List and inspect
Virtual environments
Virtual environments
Migrating from pip-tools
Compiling requirements
Compiling requirements
Syncing environments
Syncing environments
Upgrading packages
Upgrading packages
Complete migration workflow
Universal resolution
Unlike pip and pip-tools, uv can compile requirements for multiple platforms at once:requirements.txt that works across platforms:
requirements.txt
Best practices
Use uv pip sync for reproducibility
Use uv pip sync for reproducibility
uv pip sync ensures exact environment matches:pip install -r, this removes extraneous packages.Lock for multiple platforms
Lock for multiple platforms
Use
--universal for cross-platform projects:Separate development dependencies
Separate development dependencies
Use multiple requirements files:Then compile:
requirements-dev.in
Consider migrating to projects
Consider migrating to projects
For new work, uv projects provide:
- Automatic environment management
- Cross-platform lockfiles by default
- Simplified dependency management
- No manual activation needed
Next steps
pip compatibility
Understand differences from pip
Migration guide
Migrate from pip to uv projects
Working with projects
Use uv’s project interface instead
pip interface docs
Full pip interface documentation