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
path[]
required
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
path
Write compiled requirements to a file.If the file exists, its pinned versions are used as preferences during resolution (unless
--upgrade is specified).string
Output format:
requirements-txt or pylock.Default: Inferred from --output-file extension, otherwise requirements-txtConstraints and Overrides
path[]
Constrain package versions without requiring installation.Environment:
UV_CONSTRAINTpath[]
Override package versions, ignoring dependencies.Environment:
UV_OVERRIDEpath[]
Exclude packages from resolution.Environment:
UV_EXCLUDEpath[]
Constrain build dependencies when building from source.Environment:
UV_BUILD_CONSTRAINTOptional Dependencies
string[]
Include optional dependencies (extras) from
pyproject.toml.Include all optional dependencies.
string[]
Include dependency groups from
pyproject.toml.Resolver Options
Upgrade all packages to the latest compatible versions.
requirement[]
Upgrade specific packages while keeping others pinned.
string
Resolution strategy: Environment:
highest, lowest, or lowest-direct.Default: highestUV_RESOLUTIONstring
Pre-release handling: Environment:
disallow, allow, if-necessary, explicit, or if-necessary-or-explicit.Default: if-necessary-or-explicitUV_PRERELEASEstring
Version selection strategy:
requires-python or fewest.Default: requires-pythonEnvironment: UV_FORK_STRATEGYOnly add explicitly listed packages, not their dependencies.
Output Formatting
Include extras in output file.By default, uv strips extras as dependencies are already included.
Include environment markers in output.
Exclude comments indicating package sources.
string
Annotation comment style:
line, split.Default: splitExclude the header comment from output.
string
Custom command for header (for build script wrappers).Environment:
UV_CUSTOM_COMPILE_COMMANDInclude
--index-url and --extra-index-url in output.Include
--find-links in output.Include
--no-binary and --only-binary in output.Include index source in comments.
package[]
Omit specific packages from output (but include dependencies).Equivalent to pip-compile’s
--unsafe-package.Hash Generation
Include distribution hashes in output.
Python Environment
string
Python interpreter for building source distributions.Also determines minimum Python version unless Environment:
--python-version is provided.UV_PYTHONUse system Python instead of virtual environment.Environment:
UV_SYSTEM_PYTHONversion
Minimum Python version to support (e.g.,
3.8 or 3.8.17).triple
Target platform triple (e.g.,
x86_64-unknown-linux-gnu).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
Don’t build source distributions. Only use pre-built wheels.Alias for
--only-binary :all:package[]
Build specific packages from source.
package[]
Only use pre-built wheels for specific packages.
key=value[]
Pass settings to the PEP 517 build backend.
package:key=value[]
Pass package-specific settings to build backends.
Disable build isolation. Assumes build dependencies are already installed.Environment:
UV_NO_BUILD_ISOLATIONpackage[]
Disable build isolation for specific packages.
Index Options
url[]
Package indexes to use (in addition to default).Environment:
UV_INDEXurl
Default package index (replaces PyPI).Environment:
UV_DEFAULT_INDEXurl
Deprecated: Use
--default-index instead.Environment: UV_INDEX_URLurl[]
Deprecated: Use
--index instead.Environment: UV_EXTRA_INDEX_URLpath|url[]
Additional locations to search for packages.Environment:
UV_FIND_LINKSIgnore package indexes, only use
--find-links.string
Index selection strategy:
first-index, unsafe-first-match, or unsafe-best-match.Default: first-indexEnvironment: UV_INDEX_STRATEGYstring
Keyring provider for authentication:
disabled, subprocess.Default: disabledEnvironment: UV_KEYRING_PROVIDERVersion Constraints
date
Exclude packages uploaded after the specified date.Environment:
UV_EXCLUDE_NEWERpackage=date[]
Exclude specific packages uploaded after dates.
string
Link mode for build environments:
clone, copy, hardlink, symlink.Default: clone on macOS/Linux, hardlink on WindowsEnvironment: UV_LINK_MODEuv Extensions
string
PyTorch backend: Environment:
cpu, cu126, cu124, cu121, cu118, or auto.Preview feature. May change in future releases.
UV_TORCH_BACKENDIgnore
tool.uv.sources in pyproject.toml.Environment: UV_NO_SOURCESpackage[]
Ignore sources for specific packages.Environment:
UV_NO_SOURCES_PACKAGECache Options
Refresh all cached data.
package[]
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