pdm

pdm is a modern package and project manager for Python. It uses pyproject.toml for project metadata and dependency specification. It resolves and pins versions in a lock file for reproducible installs, and can manage per-project environments.

Installation and Setup

Install it from PyPI:

Windows PowerShell
(venv) PS> py -m pip install pdm
Shell
(venv) $ python -m pip install pdm

Initialize a project and create pyproject.toml:

Shell
$ pdm init

Key Features

  • Centralizes project metadata and dependency declarations in pyproject.toml.
  • Locks resolved versions in pdm.lock to support reproducible installs across machines and CI systems.
  • Manages isolated project environments and supports PEP 582 (__pypackages__) as an alternative workflow.
  • Organizes dependencies into groups like dev and exports pinned requirements when you need a requirements.txt file.
  • Runs tools inside the project environment via pdm run and supports declarative scripts in [tool.pdm.scripts].
  • Builds wheels and source distributions through a PEP 517–based build workflow with pdm build.

Usage

Create an environment and select a Python interpreter for the project:

Shell
$ pdm venv create -n py314

Add and remove dependencies:

Shell
$ pdm add "httpx>=0.25"
$ pdm remove httpx

Work with groups:

Shell
$ pdm add -G dev pytest

Lock the project:

Shell
$ pdm lock
$ pdm install # Sync env to the lockfile
$ pdm update  # Refresh locked versions

Define a scripts inside the environment:

TOML pyproject.toml
[tool.pdm.scripts]
tests = "pytest -q"

Run the script:

Shell
$ pdm run tests

Export pinned requirements:

Shell
$ pdm export -o requirements.txt

Build distributable artifacts:

Shell
$ pdm build

By Leodanis Pozo Ramos • Updated Dec. 15, 2025