The pip Interface
Not every Python workflow is, or should
become, a uv project. Scripts run by
other systems, environments built by
Dockerfiles and CI recipes, a colleague's
setup instructions written in pip — these
work, and changing them wholesale to
adopt a tool is how tools get resented.
So uv carries a second face, deliberately
old-fashioned: uv pip, a
reimplementation of pip's core commands
at uv's speed, which operates on an
ordinary virtual environment and asks for
nothing else. No pyproject.toml, no
lockfile, no conversion.
The interface is a guest, and it behaves
like one: it works on the environment
that is active (or named with
--python), it refuses to guess, and —
as you will see — it refuses to pour
packages into a system Python by default,
which is the old pile's worst habit,
designed out.
Making an environment to feed it
The pip interface does not care who built
the environment. The lab used Python's
own venv module, to make the point:
python3 -m venv throwaway
export VIRTUAL_ENV=$PWD/throwaway
uv's own uv venv makes one faster and
with a chosen interpreter (transcript
uv-lab/transcripts/t18-uv-venv.txt):
$ uv venv demo-venv
Using CPython 3.13.18
Creating virtual environment at: demo-venv
Activate with: source demo-venv/bin/activate
Either way, what you have is a standard virtual environment, indistinguishable from any other tool's.
Installing, listing, freezing
(transcript uv-lab/transcripts/t11-uv-pip.txt):
$ uv pip install cowsay
Using Python 3.12.3 environment at: throwaway
Resolved 1 package in 6ms
Installed 1 package in 4ms
+ cowsay==6.1
$ uv pip list
Using Python 3.12.3 environment at: throwaway
Package Version
------- -------
cowsay 6.1
pip 24.0
$ uv pip freeze
Using Python 3.12.3 environment at: throwaway
cowsay==6.1
pip==24.0
Every line will be familiar to a pip
user, down to freeze printing the
name==version list that a thousand
scripts consume. Note the first line of
each answer: uv says which environment
it used, out loud, every time. The
package then ran from the environment's
own bin, proving the install is real
and ordinary:
$ ./throwaway/bin/cowsay -t "installed the pip way"
| installed the pip way |
Two things the pip interface does not
do, by design. It does not keep a
lockfile — freeze is a snapshot you ask
for, not a record it maintains — and it
does not stop you resolving a different
set tomorrow. That is not a flaw; it is
the honest semantics of the workflow it
replaces. When you find yourself wanting
the record kept, you have outgrown the
interface, and the project commands of
chapters 4–10 are the way up.
The refusal
With no environment active and none
named, the lab asked anyway (transcript
uv-lab/transcripts/t14-pip-no-venv.txt):
$ uv pip install cowsay
error: No virtual environment found; run `uv venv` to create an environment, or pass `--system` to install into a non-virtual environment
pip, asked the same question, would have
written into the system Python (or, on a
modern distro, argued with the OS about
it). uv stops and names the escape hatch:
--system, for when you truly mean it —
a container, a machine that exists to be
rebuilt. The lab did not use --system
anywhere in this guide, and the chapter
does not either: needing it is usually a
sign that an environment is what's
actually wanted.
The quiet successor: uv pip compile
One pip-interface command does keep a
record, and it is the one pip-tools built
its reputation on. Give uv pip compile
a loose requirements.in — the human
list, rich on a line — and it writes
the exact, pinned requirements.txt:
(transcript uv-lab/transcripts/t12-pip-compile.txt):
$ uv pip compile requirements.in -o requirements.txt
Resolved 4 packages in 8ms
# This file was autogenerated by uv via the following command:
# uv pip compile requirements.in -o requirements.txt
markdown-it-py==4.2.0
# via rich
mdurl==0.1.2
# via markdown-it-py
pygments==2.21.0
# via rich
rich==15.0.0
# via -r requirements.in
Every version pinned, every pin annotated
with why it is there — the # via
comments are pip-tools' beloved invention,
kept. A workflow that ships a
requirements.txt can adopt uv here, and
only here, and gain a resolver that
finishes before the old one had cleared
its throat — with the file format, and
its consumers, unchanged.