
Setting up a Python project usually means three tools. pyenv picks the interpreter. venv creates the isolated environment. pip installs the packages. Add pip-tools or Poetry for lockfiles and pipx for command-line tools, and you're juggling five.
uv replaces all of them with one program. It's written in Rust, and its README says it's 10 to 100 times faster than pip. I haven't benchmarked that claim, but the bigger win is simpler: one tool, one set of commands.
Versions: uv is still pre-1.0 and ships breaking changes in minor releases. The latest release at the time of writing was 0.13.9, from 17 November 2026. The examples were run on uv 0.11.32, and where 0.12 and 0.13 changed a default, the post says so.
The old way and the uv way
Job | Before | With uv |
|---|---|---|
Install a Python version |
|
|
Pin a project's Python |
|
|
Create an environment |
|
|
Add a dependency |
|
|
Install a requirements file |
|
|
Lock dependencies |
|
|
Run in the environment |
|
|
Run a one-off tool |
|
|
Install a tool |
|
|
Install uv
The standalone installer works on macOS and Linux. Read the script first if you prefer:
curl -LsSf https://astral.sh/uv/install.sh | less # inspect it
curl -LsSf https://astral.sh/uv/install.sh | sh # install itOther options are pip install uv, brew install uv and winget install --id=astral-sh.uv -e.
Heads up:
uv self updateonly works if you used the standalone installer. If you installed another way, upgrade with that tool, for examplepip install --upgrade uv.
Python versions, without pyenv
uv python install 3.13 # download and install
uv python list # see what's available and installed
uv python pin 3.13 # write .python-version for this project
uv python upgrade # move managed versions to the latest patch releaseuv doesn't compile Python. It downloads prebuilt builds from Astral's python-build-standalone project and stores them under its own data directory. It also puts a versioned executable like python3.13 in ~/.local/bin. The experimental --default flag adds plain python and python3 too.
You often don't need to run uv python install at all. Commands like uv venv and uv run download a Python automatically when they can't find one. Set UV_PYTHON_DOWNLOADS=never if you'd rather control that.
Two things differ from pyenv:
The choice is per project. uv looks at the project's
.python-versionandrequires-python, so it doesn't swap your whole shell'spythonfor you.The list of versions is frozen per release. To get a brand-new Python, you may need to upgrade uv first.
Heads up: since uv 0.13, a bare
uv python installinstalls Python 3.15, because that became the default stable version. Name the version you want, and useuv python pinso every command in the project agrees.
Projects: the venv, pip and lockfile in one
uv init myapp
cd myapp
uv add requests
uv run myappuv init creates this:
myapp/
├── .git/
├── .gitignore
├── .python-version
├── README.md
├── pyproject.toml
└── src/
└── myapp/
└── __init__.pyThe key parts of the generated pyproject.toml are a console script and a build system:
[project.scripts]
myapp = "myapp:main"
[build-system]
requires = ["uv_build>=…,<…"] # bounds match your uv version
build-backend = "uv_build"Heads up: this packaged layout became the default in uv 0.12. Older versions created a single
main.pyand no build system. Pass--no-packageto get that simpler layout. When you upgrade uv, you may also need to loosen the upper bound onuv_build, as the release notes explain.
The first uv run or uv add creates two more things:
.venv/, the project's virtual environment. uv adds it to.gitignorefor you.uv.lock, the exact resolved versions of every dependency.
You never activate the environment. uv run handles it, and it keeps everything in sync first:
flowchart TD
A["uv run command"] --> B{"Environment exists?"}
B -- No --> C["Create .venv with the pinned Python"]
B -- Yes --> D{"uv.lock matches pyproject.toml?"}
C --> D
D -- No --> E["Re-lock the dependencies"]
D -- Yes --> F["Sync the environment"]
E --> F
F --> G["Run your command"]The lockfile
uv.lock is a cross-platform file that records exact versions for every operating system, architecture and Python version. Commit it. Don't edit it by hand. A few commands cover day-to-day use:
uv add --dev pytest # add to the dev dependency group
uv remove requests # remove a dependency
uv lock --upgrade-package requests # upgrade one package, keep the rest
uv sync --locked # install exactly the lockfile, or fail
uv sync --no-dev # leave the dev group out
uv export --no-hashes # print a requirements.txt-style listIn CI and Docker, use uv sync --locked. If someone changed pyproject.toml without updating the lockfile, the command stops with an error telling you to run uv lock, which is exactly what you want from a build.
Heads up: don't run
uv pip installinside a project's environment. The docs recommenduv addfor anything that belongs to the project, so the lockfile andpyproject.tomlstay in agreement.
Scripts and tools
Single-file scripts can declare their own dependencies in a comment block, a standard called PEP 723. uv writes the block for you, reads it when you run the script, and builds a throwaway environment:
uv init --script report.py --python 3.12
uv add --script report.py requests
uv run report.pyAfter those commands, the top of report.py looks like this, and you write the rest:
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "requests",
# ]
# ///
import requests
print(requests.get("https://example.com").status_code)The script's dependencies stay out of your project's environment, so nothing leaks between them.
Command-line tools work like pipx:
uvx ruff check . # run once in a temporary environment
uv tool install ruff # install it for good
uv tool list # see what's installeduvx is shorthand for uv tool run.
Migrating an existing project
You can move in two steps, and you can stop after the first.
Step 1: swap pip for uv pip. Nothing else changes:
uv venv
uv pip install -r requirements.txtIf you use pip-tools, the same idea applies:
uv pip compile requirements.in -o requirements.txt
uv pip sync requirements.txtStep 2: move to a uv project. Import the requirements, then retire the file:
uv init --no-package
uv add -r requirements.txt--no-package keeps it a plain application without a build system, which suits most existing apps. uv add -r then copies each requirement into pyproject.toml and creates the lockfile. Once you've committed pyproject.toml and uv.lock, you can delete requirements.txt. If a tool still needs one, uv export generates it.
Where uv pip differs from pip
uv pip is a drop-in replacement for common pip workflows, but the docs are upfront that it isn't an exact clone. These differences matter most:
Virtual environments by default. pip installs globally when no environment is active. uv installs into the active environment, or into a
.venvit finds in the current directory or a parent. With neither, it stops and asks you to create one. Pass--systemor--pythonto opt in to anything else.Different config. uv doesn't read
pip.conforPIP_INDEX_URL. UseUV_INDEX_URL, auv.tomlfile, or a[tool.uv.pip]section instead.Multiple indexes. uv searches indexes in order and takes versions only from the first index that has the package, which protects against dependency-confusion attacks. pip considers all indexes at once.
Pre-releases. Since uv 0.12, it prefers stable versions and only falls back to pre-releases when it must.
Gotchas
Pin uv in CI. Because it's pre-1.0, a new minor version can change behavior. Pin the version and read the changelog before you bump it.
Corporate networks. If TLS certificate errors appear behind a proxy, try
UV_SYSTEM_CERTS=trueto use the operating system's certificate store.Docker. uv publishes an image at
ghcr.io/astral-sh/uv.Old habits.
python -m venvandpipstill work. You can adopt uv one project at a time.
Five commands to remember
uv python install 3.13gets you an interpreter.uv initstarts a project.uv addadds a dependency.uv runruns anything inside the project environment.uv sync --lockedinstalls exactly what the lockfile says.
Pick one small project, run uv init and uv add -r requirements.txt, and see how it feels. The old tools will still be there if you need them.
Comments(0)
Join the discussion by logging into your account.
No comments yet. Be the first to comment!