uv pip compile resolves dependencies and creates a locked requirements file. It is compatible with pip-compile from pip-tools but offers significantly faster performance.
Usage
Arguments
Input Sources
Input files to compile.Supported formats:
requirements.inor.txt.pyfiles with inline metadatapylock.tomlpyproject.toml,setup.py,setup.cfg
- to read from stdin.Output Options
Write compiled requirements to a file.If the file exists, its pinned versions are used as preferences during resolution (unless
--upgrade is specified).Output format:
requirements-txt or pylock.Default: Inferred from --output-file extension, otherwise requirements-txtConstraints and Overrides
Constrain package versions without requiring installation.Environment:
UV_CONSTRAINTOverride package versions, ignoring dependencies.Environment:
UV_OVERRIDEExclude packages from resolution.Environment:
UV_EXCLUDEConstrain build dependencies when building from source.Environment:
UV_BUILD_CONSTRAINTOptional Dependencies
Include optional dependencies (extras) from
pyproject.toml.--all-extras
Include all optional dependencies.
Include dependency groups from
pyproject.toml.Resolver Options
-U, --upgrade
Upgrade all packages to the latest compatible versions.
Upgrade specific packages while keeping others pinned.
Resolution strategy: Environment:
highest, lowest, or lowest-direct.Default: highestUV_RESOLUTIONPre-release handling: Environment:
disallow, allow, if-necessary, explicit, or if-necessary-or-explicit.Default: if-necessary-or-explicitUV_PRERELEASEVersion selection strategy:
requires-python or fewest.Default: requires-pythonEnvironment: UV_FORK_STRATEGY--no-deps
Only add explicitly listed packages, not their dependencies.
Output Formatting
--no-strip-extras
Include extras in output file.By default, uv strips extras as dependencies are already included.
--no-strip-markers
Include environment markers in output.
--no-annotate
Exclude comments indicating package sources.
Annotation comment style:
line, split.Default: split--no-header
Exclude the header comment from output.
Custom command for header (for build script wrappers).Environment:
UV_CUSTOM_COMPILE_COMMAND--emit-index-url
Include
--index-url and --extra-index-url in output.--emit-find-links
Include
--find-links in output.--emit-build-options
Include
--no-binary and --only-binary in output.--emit-index-annotation
Include index source in comments.
Omit specific packages from output (but include dependencies).Equivalent to pip-compile’s
--unsafe-package.Hash Generation
--generate-hashes
Include distribution hashes in output.
Python Environment
Python interpreter for building source distributions.Also determines minimum Python version unless Environment:
--python-version is provided.UV_PYTHON--system
Use system Python instead of virtual environment.Environment:
UV_SYSTEM_PYTHONMinimum Python version to support (e.g.,
3.8 or 3.8.17).Target platform triple (e.g.,
x86_64-unknown-linux-gnu).--universal
Create a universal resolution for all platforms and Python versions.The specified
--python-version is treated as a lower bound.Implies --no-strip-markers.Build Options
--no-build
Don’t build source distributions. Only use pre-built wheels.Alias for
--only-binary :all:Build specific packages from source.
Only use pre-built wheels for specific packages.
Pass settings to the PEP 517 build backend.
Pass package-specific settings to build backends.
--no-build-isolation
Disable build isolation. Assumes build dependencies are already installed.Environment:
UV_NO_BUILD_ISOLATIONDisable build isolation for specific packages.
Index Options
Package indexes to use (in addition to default).Environment:
UV_INDEXDefault package index (replaces PyPI).Environment:
UV_DEFAULT_INDEXDeprecated: Use
--default-index instead.Environment: UV_INDEX_URLDeprecated: Use
--index instead.Environment: UV_EXTRA_INDEX_URLAdditional locations to search for packages.Environment:
UV_FIND_LINKS--no-index
Ignore package indexes, only use
--find-links.Index selection strategy:
first-index, unsafe-first-match, or unsafe-best-match.Default: first-indexEnvironment: UV_INDEX_STRATEGYKeyring provider for authentication:
disabled, subprocess.Default: disabledEnvironment: UV_KEYRING_PROVIDERVersion Constraints
Exclude packages uploaded after the specified date.Environment:
UV_EXCLUDE_NEWERExclude specific packages uploaded after dates.
Link mode for build environments:
clone, copy, hardlink, symlink.Default: clone on macOS/Linux, hardlink on WindowsEnvironment: UV_LINK_MODEuv Extensions
PyTorch backend: Environment:
cpu, cu126, cu124, cu121, cu118, or auto.Preview feature. May change in future releases.
UV_TORCH_BACKEND--no-sources
Ignore
tool.uv.sources in pyproject.toml.Environment: UV_NO_SOURCESIgnore sources for specific packages.Environment:
UV_NO_SOURCES_PACKAGECache Options
--refresh
Refresh all cached data.
Refresh cached data for specific packages.
Examples
Basic Compilation
With Extras
Upgrading Dependencies
Universal Resolution
With Constraints
Hash Generation
Custom Output Format
Custom Indexes
Cross-Platform
Build Options
pip-tools Compatibility
uv pip compile is designed to be compatible with pip-compile from pip-tools:
Differences from pip-compile
- Performance: uv is significantly faster (10-100x)
- Output file: uv requires explicit
-oflag; pip-compile infers it - Markers: uv strips markers by default; use
--no-strip-markersfor pip-compile behavior - Extras: uv strips extras by default; use
--no-strip-extrasfor pip-compile behavior - Resolution: uv uses a more sophisticated resolver
Migration from pip-compile
Output Format
The default output is arequirements.txt file:
--format pylock, output is in PEP 751 format:
Related Commands
uv pip install- Install packagesuv pip sync- Sync environment with lockfileuv lock- Lock project dependencies