Project setup
pdm init
Create pyproject.toml interactively
pdm init --python <ver>
Init with a Python version or path
pdm init --lib
Init a distributable package
pdm new <path>
Create a new project folder
pdm init --backend <name>
Pick the build backend
pdm import <file>
Import from Pipfile, Poetry or requirements
pdm use <python>
Select the project interpreter
pdm use -f
Pick the first match, no install
pdm info
Show project and environment info
pdm info --where
Print the project root
pdm fix
Repair project issues after an upgrade
Add and remove
pdm add <pkg>
Add a dependency and install it
pdm add <pkg>==<ver>
Add with a version pin
pdm add -d <pkg>
Add a development dependency
pdm add -G <group> <pkg>
Add to a named group
pdm add -e <path>
Add a local package in editable mode
pdm add --no-sync <pkg>
Edit pyproject.toml, skip installing
pdm add --dry-run <pkg>
Preview what would change
pdm add --save-exact <pkg>
Save an exact version specifier
pdm add --pre <pkg>
Allow pre-releases
pdm remove <pkg>
Remove a dependency
pdm remove -d <pkg>
Remove a dev dependency
pdm remove -G <group> <pkg>
Remove from a named group
Lock and install
pdm install
Install from the lock, locking if stale
pdm lock
Resolve and write pdm.lock
pdm sync
Install exactly what the lock says
Never changes the lock; use it in CI and on servers.
pdm install --frozen-lockfile
Install without touching the lock
pdm install --check
Fail if the lock is out of date
pdm install --prod
Skip dev dependencies
pdm install -G <group>
Include an extra group
pdm install -G :all
Include every group
pdm install --no-self
Skip installing the project itself
pdm lock --check
Check the lock is current and quit
pdm lock --refresh
Refresh hashes without re-resolving
pdm lock -G :all
Lock all declared groups
pdm lock --platform <name>
Lock for another platform
pdm lock --update-reuse
Keep existing pins when re-locking
pdm sync --clean
Remove packages not in the lock
pdm sync --reinstall
Force reinstall everything
pdm install --dry-run
Show changes without applying them
Run
pdm run <cmd>
Run a command in the env
pdm run python <file>
Run a script with the env's Python
pdm run <script> [args]
Run a [tool.pdm.scripts] entry
pdm run -l
List defined scripts
pdm run --env KEY=VALUE <cmd>
Set an env var for the run
pdm run --env-file <file>
Load a dotenv file for the run
pdm run --working-dir <dir>
Run in another folder
pdm run --venv <name> <cmd>
Run in a named virtualenv
pdm run --site-packages <cmd>
Also load the interpreter's site-packages
pdm run --recreate <script>
Rebuild a self-contained script's env
Virtualenvs and Python
pdm venv create
Create a virtualenv for the project
pdm venv create --with uv
Create it with another backend
pdm venv create --name <name>
Create a named virtualenv
pdm venv list
List the project's virtualenvs
pdm venv activate
Print the activate command
pdm venv remove <name>
Delete a virtualenv
pdm venv purge
Delete all virtualenvs of the project
pdm python install <ver>
Download a Python interpreter
pdm python list
List interpreters PDM manages
pdm python find
Search for an interpreter
pdm python remove <ver>
Remove an installed interpreter