uv vs pip for Python Installs, Lockfiles and CI
Both install packages from PyPI into a Python environment. pip ships with Python and installs what it is given; uv is a single binary that also creates the environment, installs Python and locks the project for every platform at once.
By Build Stack Review · Last reviewed
The short answer
Use uv when you want one tool to own the chain: the Python version (.python-version), the virtual environment, and a lockfile (uv.lock) resolved once for every operating system and checked in CI with uv sync --locked. Use pip when the environment is already decided for you (a container base image, a platform's Python, a build that runs pip install -r requirements.txt) and the job is to install a fully pinned list into it.
You don't have to move all at once. uv pip install reads the same requirements files and most of the same flags as pip, so CI can switch first. And because uv can export its lock as requirements.txt or the standard pylock.toml, which pip 26.1 and later can install from (still marked experimental), a team can lock with uv and keep installing with pip where it must.
uv
A Python package and project manager from Astral, written in Rust and shipped as one binary. It has a pip-compatible interface (uv pip install, uv pip compile, uv pip sync) and a project interface (uv add, uv lock, uv sync, uv run) that keeps pyproject.toml, uv.lock and .venv in step.
pip
The Python Packaging Authority's installer, included in most Python installs through ensurepip. It resolves and installs packages into the Python that runs it; creating the virtual environment and choosing the Python version are left to other tools, and its pip lock command is still experimental.
uv and pip side by side
| uv | pip | |
|---|---|---|
| What it covers | Installing packages, virtual environments (uv venv), Python versions, project locking and syncing, running tools (uvx), and building and publishing packages. | Installing, uninstalling and inspecting packages in one environment. Environments come from python -m venv or virtualenv; Python versions from somewhere else. |
| Getting it | A standalone installer, pip install uv, Homebrew and other package managers, or the ghcr.io/astral-sh/uv image. It doesn't need Python to run. | Already there in most Python installs; python -m ensurepip adds it where it isn't. Some Linux distributions package it separately. |
| Where it installs | Into the active virtual environment, or a .venv it finds in the current or a parent directory. Installing into a system Python takes --system. | Into whichever Python runs it, including a global Python when no environment is active. Distributions that mark their Python EXTERNALLY-MANAGED (PEP 668) refuse that. |
| Lockfile | uv.lock, written by uv lock, uv add and uv sync: one universal resolution for every OS, architecture and Python version in the project's requires-python, with file hashes. | pip freeze pins what is installed in this environment. pip lock (experimental since pip 25.1) writes a pylock.toml that is only guaranteed for the Python version and platform it ran on. |
| Frozen installs in CI | uv sync --locked fails if uv.lock no longer matches pyproject.toml; --frozen installs from the lock without checking. uv sync also removes packages the lock doesn't list. | pip install -r requirements.txt with every version pinned. --require-hashes fails the install on any requirement without a pinned version and hash. Packages already installed but not listed stay. |
| Resolver | PubGrub-based. Project locks are universal; uv pip compile resolves for the current platform unless you pass --universal, or a target with --python-platform. | A backtracking resolver (resolvelib) that resolves for the interpreter and platform it is running on. |
| Several package indexes | By default takes a package only from the first index that has it, to block dependency confusion. --index-strategy unsafe-best-match behaves like pip. | Combines the versions found on every index (--index-url, --extra-index-url) and picks the best, with no guaranteed order between indexes. |
| Brand-new releases | exclude-newer takes a date or a duration such as "1 week", is recorded in uv.lock, and can be set per package. Off by default. | --uploaded-prior-to takes a date, or a duration such as P3D since pip 26.1. Off by default. |
| Python versions | uv python install downloads prebuilt Python builds; uv python pin writes .python-version, which project commands follow. | None: pip runs in the Python it was installed into. pyenv, mise, the OS or a container image chooses the version. |
| Cache and disk use | One global cache. Packages are cloned (copy-on-write) into environments on macOS and Linux and hard-linked on Windows, so a version many environments use isn't copied each time where the filesystem supports it. | An HTTP and wheel cache saves downloads and builds; each environment still gets its own full copy of every package. |
| Bytecode | Doesn't compile .pyc files at install time unless you pass --compile-bytecode or set UV_COMPILE_BYTECODE=1; uv's docs recommend it for Docker images. | Compiles .pyc files during the install by default. |
| Configuration | uv.toml, [tool.uv] in pyproject.toml and UV_* variables. It doesn't read pip.conf or PIP_* variables. | pip.conf (pip.ini on Windows) and PIP_* environment variables. |
| Pinning the tool itself | required-version under [tool.uv] makes uv exit with an error when the running version doesn't match. | Pinned like any other package (for example pip install pip==26.3) in the environment or the image. |
| Licence and maintainer | Open source, MIT or Apache-2.0, developed by Astral. Still on 0.x versions: its versioning policy says what a minor release may change. | Open source, MIT, maintained by the Python Packaging Authority. |
Which to choose
Choose uv if
- You want the Python version, the virtual environment and the lockfile handled by one tool and committed as
.python-version,pyproject.tomlanduv.lock. - Developers on macOS and Windows and CI on Linux should install the same locked versions from a single lockfile.
- CI builds environments from scratch on every run and install time is a visible part of the job.
- You install internal packages from a private index and want the default to rule out dependency confusion.
Choose pip if
- The environment is fixed already: a base image or platform supplies Python and runs
pip install -r requirements.txt. - You can't add a binary to the build image, or policy allows only what ships with Python.
- You depend on pip behaviour uv doesn't offer:
--userinstalls,pip.confsettings shared across teams, or installing.eggdistributions. - Your requirements are fully pinned with hashes and you deploy to one platform, where
pip install --require-hashesalready gives identical installs.
What each one locks
pip's long-standing answer to "install the same thing again" is a requirements file with every version pinned. You get one by installing into a clean environment and running pip freeze, or with pip-tools' pip-compile. Either way the file records what resolved on that machine: a package that needs a different dependency on Windows or on an older Python, through environment markers, can be missing or wrong when the same file is installed somewhere else. pip lock writes the standard pylock.toml format (PEP 751) instead, but pip still marks it experimental and only guarantees it for the Python version and platform it ran on.
uv's project lock is universal. uv lock resolves once for every platform and every Python version the project's requires-python allows, writes markers where they differ (listing a package twice at different versions if it has to), and records the hash of each file. A developer on an Apple Silicon Mac and a Linux CI runner install from the same uv.lock. The cost is that a universal lock is more constrained: a dependency with no release that fits the whole requires-python range fails the lock, where a single-platform resolution would have passed.
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.in
pip freeze > requirements.txtuv python pin 3.13
uv add httpx # updates pyproject.toml, uv.lock and .venv
uv sync --locked # in CI: fail if uv.lock is out of dateInstalling the same environment in CI
With pip, the strict path is a fully pinned requirements file with hashes (pip-compile --generate-hashes or uv pip compile --generate-hashes writes one), installed with --require-hashes so a missing pin or a changed file fails the job. pip's secure-installs guide adds --only-binary :all:, so no source distribution runs a build on the runner. Cache pip's cache directory between runs to save downloads.
With uv, install a pinned uv version (Astral's astral-sh/setup-uv action takes a version), then run uv sync --locked. In a Dockerfile, copy pyproject.toml and uv.lock first and sync with --no-install-project, so the dependency layer stays cached until the lock changes; then copy the source and sync again. Set UV_COMPILE_BYTECODE=1 in images, since uv skips .pyc compilation by default and the first import would otherwise pay for it.
python -m pip install --require-hashes --only-binary :all: -r requirements.txtFROM python:3.13-slim
COPY --from=ghcr.io/astral-sh/uv:0.13.12 /uv /uvx /bin/
ENV UV_COMPILE_BYTECODE=1
WORKDIR /app
COPY pyproject.toml uv.lock ./
RUN uv sync --locked --no-install-project --no-dev
COPY . .
RUN uv sync --locked --no-devMoving a project from pip to uv
Start where nothing else changes: replace pip install -r requirements.txt with uv pip install -r requirements.txt (or uv pip sync to also remove what isn't listed) in CI. Three differences tend to show up. uv ignores pip.conf and PIP_INDEX_URL, so move index settings to UV_INDEX_URL or [[tool.uv.index]]. uv picks a package from the first index that has it, which changes results if you relied on --extra-index-url offering newer versions than your private index. And uv is stricter about malformed packages and indexes, which surfaces old, non-compliant releases pip quietly accepted.
Then move to the project interface. uv add -r requirements.txt copies the requirements into pyproject.toml and writes uv.lock; commit both with .python-version and delete the old file, or keep generating it with uv export --format requirements.txt for tools that still read one. Note that uv venv doesn't put pip into the environment unless you pass --seed, so scripts that call pip inside the venv need to call uv pip instead.
Where pip is catching up
pip has added much of what pushed teams to other tools, through shared standards rather than a project manager of its own (its docs say plainly that pip is not a workflow management tool). pip 25.1 installs PEP 735 dependency groups with --group and added the experimental pip lock. pip 26.0 installs the dependencies of a single-file script from its PEP 723 inline metadata with --requirements-from-script, and added --uploaded-prior-to. pip 26.1 reads pylock.toml with -r (experimental) and accepts durations for the release cutoff; pip 26.3 selects extras and groups from a pylock.toml.
Because pylock.toml is a standard, the choice is less all-or-nothing than it was: a project can lock with uv, export pylock.toml, and install it with pip on a platform that only has pip. Check each tool's changelog before you rely on this, since both sides still call parts of it experimental or preview.
When the installer isn't the problem
uv and pip decide which Python packages land in the environment. Neither controls the C compiler, OpenSSL, libpq or CUDA libraries a package builds or loads against, and uv's managed Python covers the interpreter only. If installs from the same lockfile still behave differently on a Mac and a Linux runner, the drift is usually below Python: the site's mise vs asdf comparison covers pinning runtimes, and Nix vs Docker covers pinning everything under them.
Frequently asked questions
Is uv faster than pip?
Usually, and most visibly with a warm cache, where uv links packages from its cache instead of unpacking them again. Astral publishes its own benchmarks; how much you gain depends on the project, the cache and the filesystem, so time a cold and a warm install of your own repo before deciding on speed alone.
Can uv use my existing requirements.txt?
Yes. uv pip install -r requirements.txt and uv pip sync requirements.txt read it directly, and uv add -r requirements.txt moves its entries into pyproject.toml and creates uv.lock.
Does uv replace pip-tools?
For most workflows. uv pip compile does what pip-compile does, including --generate-hashes, and adds --universal for a requirements file that covers every platform; uv pip sync does what pip-sync does.
Does uv read pip.conf?
No. uv doesn't read pip's configuration files or PIP_* environment variables. Set the equivalents in uv.toml, under [tool.uv] in pyproject.toml, or with UV_* variables such as UV_INDEX_URL.
Can pip install from uv.lock?
Not directly. Export it first: uv export --format requirements.txt gives a pinned, hashed file any pip can install, and uv export --format pylock.toml gives the standard lock format that pip 26.1 and later can read with -r (experimental).
Why is there no pip in my uv environment?
uv venv and uv sync create environments without pip, since uv installs into them itself. Use uv pip install instead, or create the environment with uv venv --seed if a tool needs pip inside it.
Sources
Tools change quickly: check versions, defaults and licence terms against each project’s own documentation before you decide.
- uv documentation
- uv: Compatibility with pip and pip-tools
- uv: Locking and syncing
- uv: Resolution (universal resolution, exclude-newer)
- uv: Exporting lockfiles
- uv: Python versions
- uv: Using uv in Docker
- uv: Using uv in GitHub Actions
- uv: Settings reference (link-mode, required-version)
- uv: Versioning policy
- pip: Changelog
- pip: pip lock
- pip: Secure installs
- pip: Repeatable installs
- pip: Pip is not a workflow management tool
- PEP 751: A file format to record Python dependencies (pylock.toml)
- PEP 668: Marking Python base environments as externally managed





