Use the uv backend¶
Make pipx use uv to create virtual environments and install packages in place of pip and venv. The CLI surface stays the same.
For why uv is faster and how pipx compares to Astral’s standalone uv tool, see Comparisons.
Make uv available¶
Install pipx with the uv extra so it ships the bundled binary:
$ pipx install pipx[uv]
Or install uv 0.9.17 or newer however you like (brew install uv, cargo install uv) and put it on PATH;
pipx picks it up. New venvs then default to uv. Existing venvs keep their recorded backend. When the uv
pipx finds is older than that, pipx warns and falls back to pip. Asking for uv explicitly (--backend uv,
PIPX_DEFAULT_BACKEND=uv, or a venv that recorded uv) with an older uv fails and asks you to upgrade it.
How pipx picks a backend¶
flowchart TD
START["new venv"] --> CLI{"--backend given?"}
CLI -->|yes| USECLI["use it"]
CLI -->|no| ENV{"PIPX_DEFAULT_BACKEND set?"}
ENV -->|yes| USEENV["use it"]
ENV -->|no| UV{"uv 0.9.17+ available?<br/>bundled or on PATH"}
UV -->|yes| USEUV["uv"]
UV -->|no| PIP["pip + venv"]
classDef decision fill:#2a9d8f,stroke:#1f7268,color:#fff;
classDef uv fill:#7c4dff,stroke:#5a34c0,color:#fff;
classDef pip fill:#3f72af,stroke:#28507d,color:#fff;
class CLI,ENV,UV decision;
class USECLI,USEENV,USEUV uv;
class PIP pip;
Choose a backend explicitly¶
$ pipx install black --backend pip
$ pipx install ruff --backend uv
$ PIPX_DEFAULT_BACKEND=uv pipx install ruff
$ pipx environment --value PIPX_RESOLVED_BACKEND
install, install-all, inject, upgrade, upgrade-all, reinstall, reinstall-all, and run
all accept --backend. Switch an installed venv with pipx reinstall NAME --backend uv.
What changes under uv¶
pipx creates venvs with
uv venv. The venv contains nopipand nopipx_shared.pthfile.pipx runpiprunsuv pip <args> --python <venv>/bin/python. uv rejects flags it does not understand rather than dropping them silently.pipx runexecsuv tool run; its cache lives in uv’s cache directory. Pass--no-cacheto skip it or--refreshto rebuild the cached environment.pipx run script.pyexecsuv run --active --script script.pyfor PEP 723 inline scripts, withVIRTUAL_ENVpointing at an environment in pipx’s cache.--cooldown DAYS(orPIPX_COOLDOWN) maps to uv’s--exclude-newer P{DAYS}D. See Dependency cooldown.uv reads your user config (
~/.config/uv/uv.toml,%APPDATA%\uv\uv.tomlon Windows), the system config (/etc/uv/uv.toml), and aUV_CONFIG_FILE, but no project config from your working directory or the script’s directory. pipx setsUV_PROJECT(--projectforuv run --script) toPIPX_HOME, replacing anyUV_PROJECTyou set, so uv looks for auv.tomlor apyproject.tomlwith a[tool.uv]table inPIPX_HOMEand each of its parents up to the filesystem root.With the default
PIPX_HOMEunder your home directory, the parents uv searches for project config belong to you or to root. IfPIPX_HOME(orPIPX_GLOBAL_HOME) sits below a directory other accounts can write, such as/tmpor a group-writable share, any of them can place auv.tomlthere that steers pipx’s uv calls; keep it in a directory only you can write.A
--project,--directoryor--config-filein--pip-argspoints uv at other configuration, and pipx records it with the environment. On POSIX, a laterupgradeorreinstallrefuses to replay it when another account can change the path. See Metadata.
Limitations¶
pipx install pip --backend uverrors: a uv venv has no pip. Use--backend pip.pipx run --backend uvhonors[pipx.run]entry points only where it builds a venv, which with--specmeans an<app>that differs from the spec’s normalized distribution name, or a spec carrying no name at all. An<app>matching that name goes touv tool run, which reads console scripts only, so reach for--backend pipto override a console script of the same name.Some
--pip-argsvalues have nouv tool runequivalent (--editable,--no-build-isolation); pipx errors instead of dropping them. See Use a private index for which flags uv translates.pipx run --backend uvrejects--system-site-packages, since uv builds the environment. Use--backend pipwhen you need it.pipx run --backend uvagainst URL or named-pipe scripts falls back to a pipx-managed venv, becauseuv run --scriptreads PEP 723 metadata off disk and runtime-fetched content has no on-disk path. pipx logs a warning.pipx runfalls back to a pipx-managed venv when it has to infer the script name: from a VCS URL, a local project path, or a name it normalizes (pipx run pip_searchinstallspip-search).uv tool runtakes that name up front and would guess it from the package, so pipx installs the package first and runs the script it declares. Passpipx run --spec <spec> <normalized-name>to keep uv’s cache when the package declares a matching console script. pipx installs a spec with no distribution name (a path, a URL, a direct reference) twice, once to learn its name and once into the run venv.
Cache layout¶
Under the uv backend, pipx run APP caches in UV_CACHE_DIR instead of PIPX_VENV_CACHEDIR, while
pipx run script.py keeps the script’s environment in PIPX_VENV_CACHEDIR. Switching the default backend on a host
that already used pipx run leaves the old pipx cache behind. Find it with pipx cache dir and remove its
environments with pipx cache purge. The 14-day expiry sweep pipx applies to its own cache does not extend to uv’s
cache, which uv manages on its own schedule (uv cache clean).
Verify it¶
$ pipx environment --value PIPX_RESOLVED_BACKEND
It prints uv when pipx will use the uv backend for new venvs.