Python — Package Management (uv and pipx)

Python — Package Management (uv and pipx)

Overview

Two complementary tools for Python package management:

  • uv — fast, all-in-one project manager, virtual environment manager, and pip replacement (Rust-based)
  • pipx — installs CLI tools in isolated environments; the standard for global Python CLI tools

They overlap in the “install CLI tool globally” use case — uv tool install vs pipx install. uv is the modern default; pipx is still widely used.


uv — The All-in-One Python Tool

uv is a Rust-based drop-in replacement for pip, pip-tools, venv, and package management — significantly faster than any Python-native tool.

Project Management (pyproject.toml)

CommandDescription
uv initInitialise a new Python project
uv add <package>Add a dependency to the project
uv remove <package>Remove a dependency
uv syncSync the virtual environment with project dependencies
uv run <command>Run a script or command in the project’s environment

Virtual Environments & Python Versions

CommandDescription
uv venvCreate a new virtual environment (default: .venv)
uv python install <version>Install a specific Python version (e.g. 3.12)
uv python listList available and installed Python versions

Tool Management (pipx alternative)

CommandDescription
uv tool install <tool>Install a CLI tool globally in an isolated environment
uv tool upgrade-allUpgrade all installed tools
uvx <tool>Run a tool on-the-fly without installing it

Pip Interface (pip / pip-tools alternative)

CommandDescription
uv pip install <package>Install a package into the active environment
uv pip compile reqs.inLock dependencies into a requirements.txt
uv pip sync reqs.txtSync environment exactly to a requirements.txt
uv pip freezeList currently installed packages and versions

pipx — Global CLI Tool Installer

pipx installs Python CLI applications in isolated virtual environments — each tool gets its own environment, preventing dependency conflicts.

When to Use pipx

Use for global CLI tools you want available system-wide: black, mypy, httpie, cookiecutter, etc. Do not use for libraries you import in code or for project-specific dependencies (use uv or pip for those).

Installation

1
2
3
4
5
6
7
8
# Debian/Ubuntu Linux
sudo apt install pipx
pipx ensurepath  # add to PATH
# restart terminal

# Windows / other
pip install --user pipx
pipx ensurepath

Common Commands

CommandDescription
pipx install <package>Install an application
pipx listList installed applications
pipx upgrade <package>Upgrade an application
pipx upgrade-allUpgrade all applications
pipx uninstall <package>Uninstall an application
pipx run <package>Run application temporarily (no install)

Decision Guide

ScenarioTool
New Python project with dependenciesuv init + uv add
Isolated virtual environmentuv venv
Install a specific Python versionuv python install
Install a global CLI tooluv tool install or pipx install
Run a tool without installinguvx <tool>
Lock/sync requirements.txt workflowuv pip compile + uv pip sync
Replace pip in existing workflowuv pip install
Manage the Python version itselfmise use python@3.12 (see DevOps — Tool Version Management (mise))

See Also

Trending Tags