uv pip sync synchronizes a Python environment to exactly match a requirements file or lockfile. Unlike uv pip install, it removes packages that aren’t in the file.
Usage
Arguments
Input Files
path[]
required
Files to sync from.Supported formats:
requirements.txt.pyfiles with inline metadatapylock.tomlpyproject.toml,setup.py,setup.cfg
- to read from stdin.Constraints
path[]
Constrain package versions during sync.Environment:
UV_CONSTRAINTpath[]
Constrain build dependencies when building from source.Environment:
UV_BUILD_CONSTRAINTOptional Dependencies
string[]
Include optional dependencies (extras) from
pylock.toml or pyproject.toml.Include all optional dependencies.
string[]
Install dependency groups from
pylock.toml or pyproject.toml.Python Environment
string
Python interpreter to use.By default, syncing requires a virtual environment. Use with caution for system Python.Environment:
UV_PYTHONUse system Python instead of virtual environment.Environment:
UV_SYSTEM_PYTHONAllow installation into externally-managed Python environments.Environment:
UV_BREAK_SYSTEM_PACKAGESpath
Sync packages to the specified directory.
path
Sync packages to lib, bin folders under the specified directory.
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_ISOLATIONIndex 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_PROVIDERHash Verification
Require hash verification for all packages.All requirements must include hashes and be pinned to exact versions.Environment:
UV_REQUIRE_HASHESDisable hash verification.Environment:
UV_NO_VERIFY_HASHESVersion Constraints
version
Minimum Python version to support (e.g.,
3.8 or 3.8.17).triple
Target platform triple (e.g.,
x86_64-unknown-linux-gnu).Sync Behavior
Allow syncing with empty requirements, clearing the environment.
Validate environment after sync, detecting missing dependencies.
Show sync plan without making changes.
Reinstall all packages, ignoring existing installations.
package[]
Reinstall specific packages.
date
Exclude packages uploaded after the specified date.Environment:
UV_EXCLUDE_NEWERpackage=date[]
Exclude specific packages uploaded after dates.
string
Link mode for installations:
clone, copy, hardlink, symlink.Default: clone on macOS/Linux, hardlink on WindowsEnvironment: UV_LINK_MODECompile Python files to bytecode after installation.Environment:
UV_COMPILE_BYTECODEuv Extensions
string
PyTorch backend: Environment:
cpu, cu126, cu124, cu121, cu118, or auto.Preview feature. May change in future releases.
UV_TORCH_BACKENDCache Options
Refresh all cached data.
package[]
Refresh cached data for specific packages.
Examples
Basic Sync
With Extras
Dry Run
Hash Verification
Custom Index
Cross-Platform
Differences from pip install
uv pip sync differs from uv pip install in key ways:
Exact Sync
Expected Input
uv pip sync expects a fully resolved file (from uv pip compile or uv export):
Transitive Dependencies
If the input file is missing transitive dependencies, they won’t be installed:Use Cases
CI/CD Reproducible Builds
Development Workflow
Docker Images
Cleanup Environments
Related Commands
uv pip compile- Generate lockfileuv pip install- Install packages (keeps existing)uv sync- Sync project environment