uv pip install -r requirements.txt: venv, errors, upgrade (tested)

uv pip install -r requirements.txt installs into the active venv or the nearest .venv up the directory tree, no activation needed. Add -U to upgrade, --dry-run to preview, -c for constraints.

uv pip install -r requirements.txt is the fast drop-in for pip install -r. Measured with uv 0.13.5 on Python 3.13.5 (Linux); the transcripts ran in order in one fresh directory and are unedited.

1. Install requirements.txt into the project venv

Transcript:

$ printf 'six==1.17.0\nidna\n' > requirements.txt && uv venv -q && uv pip install -r requirements.txt
Resolved 2 packages in 2ms
Installed 2 packages in 3ms
 + idna==3.20
 + six==1.17.0
$ mkdir -p src/app && cd src/app && printf 'certifi\n' > req2.txt && uv pip install -r req2.txt
Using Python 3.13.5 environment at: /tmp/urw397/.venv
Resolved 1 package in 2ms
Installed 1 package in 3ms
 + certifi==2026.10.23
$ ls .venv/lib/python3*/site-packages | grep '^certifi-'
certifi-2026.10.23.dist-info

uv installs into the active venv (VIRTUAL_ENV) or, if none is active, the nearest .venv in the current or a parent directory: run from src/app, it printed Using Python 3.13.5 environment at: /tmp/urw397/.venv and installed there. You do not need to activate the venv. With no venv at all it stops with No virtual environment found; see uv pip install vs uv add (use --system only in containers).

2. Common errors, and constraints files

Transcript:

$ uv pip install -r requirement.txt
error: File not found: requirement.txt
[exit 2]
$ printf 'six==1.17.0\nsix==1.16.0\n' > bad.txt && uv pip install -r bad.txt
error: No solution found when resolving dependencies
  cause: Because you require six==1.17.0 and six==1.16.0, we can conclude that your requirements are unsatisfiable.
[exit 1]
$ printf 'idna\n' > requirements.txt && printf 'idna<3.10\n' > constraints.txt && uv pip install -r requirements.txt -c constraints.txt -q && uv pip list | grep idna
idna    3.9

A misspelled file name gives error: File not found; conflicting pins give No solution found when resolving dependencies with the reason. -c constraints.txt limits versions without adding packages, exactly like pip.

3. Upgrade, dry run, and another venv

Transcript:

$ uv pip install -r requirements.txt --dry-run -U
Resolved 1 package in 68ms
Would download 1 package
Would uninstall 1 package
Would install 1 package
 - idna==3.9
 + idna==3.20
$ VIRTUAL_ENV=/tmp/urw397/other uv venv -q other && VIRTUAL_ENV=/tmp/urw397/other uv pip install -r requirements.txt -q && ls other/lib/python3*/site-packages | grep -c '^idna-'
1

Already-installed packages that satisfy the file are left alone; -U upgrades them, and --dry-run shows the plan without changing anything. To target a different environment, set VIRTUAL_ENV (or pass --python /path/to/venv). To make the venv match the file exactly, removing extras, use uv pip sync requirements.txt; to produce a pinned file, see uv pip compile.

Related: uv pip compile, uv pip install vs uv add, uv ignore SSL errors, pip error: externally-managed-environment.

Frequently asked questions

Do I need to activate the venv for uv pip install -r?

No. uv uses VIRTUAL_ENV if set, otherwise the nearest .venv in the current or a parent directory.

Does uv pip install -r upgrade packages?

No, installed packages that satisfy the file are kept. Use -U, or uv pip sync to match the file exactly.

Does uv support constraints files?

Yes: uv pip install -r requirements.txt -c constraints.txt.

Written with AI assistance. Measured on 2026-10-23 with uv 0.13.5 and CPython 3.13.5 on Linux. Each transcript was produced by running the commands verbatim in one fresh directory. PlainHeaders is our extension; uv is free.