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:
Initialize a project and create pyproject.toml:
$ pdm init
Key Features
- Centralizes project metadata and dependency declarations in
pyproject.toml. - Locks resolved versions in
pdm.lockto support reproducible installs across machines and CI systems. - 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. - Organizes dependencies into groups like
devand exports pinned requirements when you need arequirements.txtfile. - Runs tools inside the project environment via
pdm runand 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:
$ pdm venv create -n py314
Add and remove dependencies:
$ pdm add "httpx>=0.25"
$ pdm remove httpx
Work with groups:
$ pdm add -G dev pytest
Lock the project:
$ pdm lock
$ pdm install # Sync env to the lockfile
$ pdm update # Refresh locked versions
Define a script inside the environment:
pyproject.toml
[tool.pdm.scripts]
tests = "pytest -q"
Run the script:
$ pdm run tests
Export pinned requirements:
$ pdm export -o requirements.txt
Build distributable artifacts:
$ pdm build
Related Resources
Tutorial
How to Manage Python Projects With pyproject.toml
Learn how to manage Python projects with the pyproject.toml configuration file. In this tutorial, you'll explore key use cases of the pyproject.toml file, including configuring your build, installing your package locally, managing dependencies, and publishing your package to PyPI.
For additional information on related topics, take a look at the following resources:
- Dependency Management With Python Poetry (Tutorial)
- uv vs pip: Managing Python Packages and Dependencies (Tutorial)
- Using Python's pip to Manage Your Projects' Dependencies (Tutorial)
- Everyday Project Packaging With pyproject.toml (Course)
- uv vs pip: Python Packaging and Dependency Management (Course)
- How to Manage Python Projects With pyproject.toml (Quiz)
- Managing Dependencies With Python Poetry (Course)
- Dependency Management With Python Poetry (Quiz)
- uv vs pip: Managing Python Packages and Dependencies (Quiz)
- A Beginner's Guide to pip (Course)
- Using Python's pip to Manage Your Projects' Dependencies (Quiz)
By Leodanis Pozo Ramos • Updated May 25, 2026