Compatibility
The official guide moves a pip and pip-tools workflow built on requirements files to a uv project. pyproject.toml takes the place of requirements.in, and uv.lock takes the place of requirements.txt. The lockfile format is specific to uv. It can hold any number of dependency groups, and it is always universal, so one file covers every platform where pip needs a lock file per platform.
The guide does not cover moving to uv’s drop-in uv pip interface, or starting from a workflow that already uses a pyproject.toml. Astral tracks both in issue #5200.
Before you switch
- Create a
pyproject.tomlwithuv initif the project has none. - Import the requirements with
uv add -r requirements.in -c requirements.txt. Passing the old lock file as constraints keeps the versions you already run. - Import development requirements into the
devgroup withuv add --dev -r requirements-dev.in -c requirements-dev.txt, and any other set into a named group with--group, for example--group docs. - Run commands with
uv run, for exampleuv run pytest, or create the environment withuv sync. uv keeps a.venvdirectory per project and syncs it for you.
Local paths, editable paths and Git dependencies in requirements.in end up in the [tool.uv.sources] table of pyproject.toml.
Pitfalls
uv add -r requirements.inalone solves for new versions, sincerequirements.indoes not pin anything. Add-c requirements.txtif nothing should change during the switch.- Platform-specific lock files cannot be passed as constraints as they are: they carry no markers and conflict. Rewrite each one first, for example
uv pip compile requirements.in -o requirements-win.txt --python-platform windows --no-strip-markers, then pass them all with repeated-c. - If
requirements-dev.inincludesrequirements.inthrough-r, strip that line before importing, or the base requirements land in the dev group. The guide pipes it throughsed '/^-r /d'intouv add --dev -r -. - Inside a project, uv uses the project’s
.venvand ignores the environment named byVIRTUAL_ENV. Pass--activeto use the active environment instead.