Skip to content

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:

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

Initialize a project and create pyproject.toml:

Language: 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, and can opt in to the standardized pylock.toml format from PEP 751.
  • Manages isolated project environments and retains opt-in support for PEP 582 (__pypackages__), although PEP 582 was rejected and PDM now recommends using virtual environments.
  • Downloads and installs Python interpreters through the pdm python command group, so you can set up a version that isn’t already on the machine.
  • 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

Install a Python interpreter that isn’t on your system yet:

Language: Shell
$ pdm python install 3.14

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

Language: Shell
$ pdm venv create --name py314 3.14

Add and remove dependencies:

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

Work with groups:

Language: Shell
$ pdm add -G dev pytest

Lock the project:

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

Define a script inside the environment:

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

Run the script:

Language: Shell
$ pdm run tests

Export pinned requirements:

Language: Shell
$ pdm export -o requirements.txt

Or export the standardized PEP 751 lock format:

Language: Shell
$ pdm export -f pylock -o pylock.toml

Build distributable artifacts:

Language: Shell
$ pdm build
A person triumphantly raises a key in front of a vault labeled pylock.toml, with a rack of colored keys, wooden crates marked with hashes, and a Python chip alongside.

Tutorial

Tool-Agnostic Python Lock Files With PEP 751 and pylock.toml

Learn how PEP 751 standardizes Python lock files with pylock.toml: generate one with pip or uv, install it with uv or pdm, and retire requirements.txt.

intermediate tools

For additional information on related topics, take a look at the following resources:

Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.


By Leodanis Pozo Ramos • Updated Oct. 31, 2026