Skip to content
Tutorials Center
My learning

Topics

Lesson 22 of 38 ยท Dependency Management

pip, uv, Poetry and PDM Compared

Compare pip, uv, Poetry, PDM and pipenv for Python dependency management, learn dependency groups from PEP 735, and pick the right tool for your project.

Python has more than one way to install and manage packages, and the choice can feel overwhelming. The good news is that the tools share the same standards underneath: they all read pyproject.toml, install the same wheels from the same indexes, and build the same environments. What differs is how much of the workflow each one does for you.

In this lesson you will see what each tool covers, how dependency groups let you separate development tools from runtime packages, and how to choose. None of these tools can run inside this page, so the commands are shown as read-only code, and the runnable example reads a real pyproject.toml the way a tool would.

The tools at a glance

Four main tools

pip Installs packages. Ships with Python.
uv Very fast. Projects, locks, Python versions.
Poetry Full project manager with its own build flow.
PDM Standards-first project manager.

Same wheels, same indexes, different workflows.

1 / 3

pip

pip is the installer that comes with Python. It installs from PyPI (or any index), resolves dependencies, and supports requirements files, constraints and hash checking. It does not create environments (that is python -m venv), does not write a lock file on its own (use pip-tools or pip freeze), and does not add dependencies to pyproject.toml for you. It is the lowest common denominator, available everywhere.

Terminal
python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate
python -m pip install -r requirements.txt

uv

uv is a single fast tool, written in Rust, that replaces pip, venv, pip-tools, pipx and more. It manages projects (uv init, uv add, uv sync), writes a universal uv.lock, installs and selects Python versions, runs scripts with inline dependencies and offers a drop-in uv pip interface for existing workflows.

Terminal
uv init demo && cd demo
uv add requests               # edits pyproject.toml, locks, installs
uv add --dev pytest           # adds to the dev dependency group
uv run pytest                 # runs in the project environment
uv sync --frozen              # CI: install exactly the lock

Poetry

Poetry was one of the first tools to offer a full project workflow: dependency declaration, resolution, poetry.lock, virtual environment handling, build and publish. Recent versions read the standard [project] table and also support its own [tool.poetry] format.

Terminal
poetry init
poetry add requests
poetry add --group dev pytest
poetry install
poetry build && poetry publish

PDM

PDM follows packaging standards closely (PEP 621 metadata, PEP 735 groups) and supports plugins and several build backends. It writes pdm.lock and can manage environments much like the others.

Terminal
pdm init
pdm add requests
pdm add -dG test pytest
pdm install

Pipenv

Pipenv combines pip and virtualenv with a Pipfile and Pipfile.lock. It is still used in older projects; new projects usually choose one of the tools above.

Comparison table

pip uv Poetry PDM
Installs packages yes yes yes yes
Creates virtual environments no (use venv) yes yes yes
Resolves a lock file no uv.lock poetry.lock pdm.lock
Edits pyproject.toml for you no yes yes yes
Installs Python itself no yes no no (via other tools)
Builds and publishes no (use build, twine) yes yes yes
Speed good very fast moderate moderate

Treat the table as a map, not a verdict: tools gain features quickly, so check the current documentation before you commit to one.

Dependency groups

Real projects need packages that users should not get: test runners, linters, documentation builders. Two standard mechanisms keep them apart.

Optional dependencies (extras) are published with the package, so users can opt in: pip install mypackage[postgres].

TOML
[project.optional-dependencies]
postgres = ["psycopg[binary]>=3.1"]

Dependency groups (PEP 735) live in a separate [dependency-groups] table and are not part of the published metadata. They are for the people working on the project.

TOML
[dependency-groups]
test = ["pytest>=8", "coverage>=7"]
lint = ["ruff>=0.5", "mypy>=1.10"]
dev = [{include-group = "test"}, {include-group = "lint"}, "pre-commit"]

A group can include another group with include-group. Installing the dev group then installs everything in it, once. Modern pip and uv can install groups (pip install --group test, uv sync --group lint).

Python Expand dependency groups like a tool

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The output shows dev expanding into the contents of test and lint plus pre-commit, and shows that groups live outside [project].

Picking a tool

  • Starting something new and want the least friction? uv covers almost the whole workflow in one fast tool.
  • Team already uses Poetry or PDM happily? Keep it. A working workflow beats a fashionable one.
  • Constrained environment, minimal dependencies, or teaching? pip with venv and pip-tools is simple and universal.
  • Publishing a library? Any of them works, because the result is a standard wheel and sdist. Make sure [project] metadata is complete (see the chapter on pyproject.toml).

The tool you pick for installing is separate from the build backend that turns source into a wheel (setuptools, hatchling, flit-core, uv_build, poetry-core, pdm-backend). You can mix them: a project built with hatchling can be managed with uv or pip.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which statement about pip is correct?

    pip is an installer. Virtual environments come from venv, locks from helper tools, and dependency editing from project managers.
  2. 2. What is the difference between an extra and a dependency group?

    Extras such as pkg[postgres] are part of the distribution's metadata. PEP 735 groups are development-only and stay out of the wheel.
  3. 3. What does include-group do in [dependency-groups]?

    It lets a group such as dev be built from smaller groups like test and lint without repeating them.
  4. 4. A project is built with hatchling but managed with uv. Is that allowed?

    The backend is named in [build-system]; any installer or manager reads that and invokes it through the standard interface.

Summary

  • All the main tools work with standard metadata and wheels; they differ in how much workflow they automate.
  • pip installs; uv, Poetry and PDM also manage environments, lock files and projects, and uv also manages Python versions.
  • Extras are published optional features; dependency groups (PEP 735) are unpublished groups for development.
  • Choose by your team's needs; migrating is easy when pyproject.toml follows the standards.

Next: Updating and Auditing Dependencies