Package Managers
This note is complete, reviewed, and considered stable.
In Python, “package management” usually spans several jobs:
- Installer/Resolver: downloads and resolves dependencies (e.g.,
pip, uv, Poetry’s installer). - Environment manager: isolates dependencies per project (e.g.,
venv,virtualenv, Conda). - Project manager: defines metadata, lock files, build/publish (e.g., Poetry, uv, Hatch, PDM, Flit).
- Tool runner: installs/runs CLI tools in isolated envs (e.g., pipx, uvx).
- Python version manager: installs/switches Python versions (e.g., pyenv, uv python).
The tools (concise profiles)
uv (Astral)
A fast, all-in-one package & project manager written in Rust. It can replace pip, pip-tools, pipx, poetry, virtualenv (and even pyenv/twine tasks) with one tool. Provides a pip-compatible interface (uv pip …), a universal lockfile, workspaces, a global cache, script support (inline deps), tool runner (uvx), and Python version management. Claimed 10–100× faster installs than pip.
Common commands
# project
uv init && uv add requests && uv lock && uv sync
uv run python app.py
# pip-compatible workflows (fast drop-in)
uv pip install -r requirements.txt
uv pip compile --universal -o requirements.txt
uv pip sync requirements.txt
# tools & Python versions
uvx ruff --version
uv python install 3.12 && uv venv --python 3.12
How to use
-
Initialize a project:
uv init -
Add dependencies:
uv add <package_name> -
Lock dependencies:
uv lock -
Install dependencies from lockfile:
uv sync -
Run scripts with dependencies:
uv run python main.py -
Use as a drop-in pip replacement:
uv pip install requests -
Run CLI tools without installing globally:
uvx black . -
Manage Python versions:
uv python install 3.11
uv venv --python 3.11
Pros
- Very fast installs/resolution; excellent cache behavior.
- One tool covers install/lock/envs/tools/publish/Python versions.
- Works with existing
requirements.txtviauv pip ….
Cons
- Newer ecosystem; some teams may still standardize on pip/Poetry/Conda.
- Feature superset can feel “heavy” if we only need a minimal pip+venv flow.
pip (and venv/virtualenv)
The default installer that talks to PyPI; pair with venv for env isolation. virtualenv is an alternative with more knobs/features; venv is stdlib and lightweight.
How to Use
-
Create a virtual environment:
python -m venv .venv -
Activate it:
-
macOS/Linux:
source .venv/bin/activate -
Windows:
.venv\Scripts\activate
-
-
Install packages:
pip install requests -
Freeze dependencies:
pip freeze > requirements.txt -
Install from requirements:
pip install -r requirements.txt
Pros
- Ubiquitous, simple; zero extra tooling.
- Works everywhere; easy to script/CI.
Cons
- No lockfile by default (we add pip-tools or switch to uv/Poetry).
- Env management is separate (venv/virtualenv).
pip-tools (pip-compile, pip-sync)
Adds deterministic lock files to pip workflows by compiling pinned requirements.txt from inputs.
How to Use
-
Install pip-tools:
pip install pip-tools -
Create a requirements.in with your dependencies:
requests
flask -
Compile to a locked requirements file:
pip-compile -
Sync environment to match the lock file:
pip-sync
Pros
- Deterministic builds while keeping plain-pip workflows.
- Familiar files (requirements.in → pinned requirements.txt).