PDM is a modern Python package manager with PEP 582 support. It installs and manages packages
in a similar way to
npm that doesn't need to create a virtualenv at all!
- PEP 582 local package installer and runner, no virtualenv involved at all.
- Simple and relatively fast dependency resolver, mainly for large binary distributions.
- A PEP 517 build backend.
- PEP 621 project metadata.
- Flexible yet powerful plug-in system.
- Opted-in centralized installation cache like pnpm.
PDM requires Python 3.7+ to be installed. It works on multiple platforms including Windows, Linux and MacOS.
There is no restriction about what Python version your project is using, but installing PDM itself needs Python 3.7+.
Recommended installation method#
PDM requires python version 3.7 or higher.
Like Pip, PDM provides an installation script that will install PDM into an isolated environment.
For security reasons, you should verify the checksum of
The sha256 checksum is:
The installer will install PDM into the user site and the location depends on the system:
You can pass additional options to the script to control how PDM is installed:
1 2 3 4 5 6 7 8 9 10
You can either pass the options after the script or set the env var value.
Other installation methods#
Install the head version of GitHub repository. Make sure you have installed Git LFS on your system.
See also: https://pypa.github.io/pipx/
By copying the Pyprojectx wrapper scripts to a project, you can install PDM as (npm-style) dev dependency inside that project. This allows different projects/branches to use different PDM versions.
To initialize a new or existing project, cd into the project folder and:
Enable PEP 582 globally#
To make the Python interpreters aware of PEP 582 packages, one need to add the
to the Python library search path.
For Windows users#
One just needs to execute
pdm --pep582, then environment variable will be changed automatically. Don't forget
to restart the terminal session to take effect.
For Mac and Linux users#
The command to change the environment variables can be printed by
pdm --pep582 [<SHELL>]. If
isn't given, PDM will pick one based on some guesses. You can run
eval "$(pdm --pep582)" to execute the command.
You may want to write a line in your
.bash_profile(or similar profiles) to make it effective when logging in.
For example, in bash you can do this:
Once again, Don't forget to restart the terminal session to take effect.
PDM supports generating completion scripts for Bash, Zsh, Fish or Powershell. Here are some common locations for each shell:
Then make sure pdm plugin is enabled in ~/.zshrc
1 2 3 4 5 6 7 8 9 10
Unicode and ANSI supports#
PDM provides a fancy terminal UI with the help of ANSI characters and unicode emojis.
It can turn on/off automatically depending on whether it is supported on your terminal.
However, if you see any garbled characters, set env var
DISABLE_UNICODE_OUTPUT=1 to turn off it.
Use with IDE#
Now there are not built-in support or plugins for PEP 582 in most IDEs, you have to configure your tools manually.
PDM will write and store project-wide configurations in
.pdm.toml and you are recommended to add following lines
Additionally, if you want to use tools from the environment (e.g.
pytest), you have to add the
__pypackages__/<major.minor>/bin directory to the
PATH variable in the corresponding
Add the following two entries to the top-level dict in
1 2 3 4
Enable PEP582 globally, and make sure VSCode runs using the same user and shell you enabled PEP582 for.
Cannot enable PEP582 globally?
If for some reason you cannot enable PEP582 globally, you can still configure each "launch" in each project:
PYTHONPATH environment variable in your launch configuration, in
For example, to debug your
1 2 3 4 5 6 7 8 9 10 11 12 13 14
If your package resides in a
src directory, add it to
PYTHONPATH as well:
If you have configured
and you see a ton of errors/warnings as a result.
you may need to create
pyrightconfig.json in the workspace directory, and fill in the following fields:
1 2 3
Then restart the language server or VS Code and you're good to go. In the future (microsoft/pylance-release#1150), maybe the problem will be solved.
Using Jupyter Notebook?
If you wish to use pdm to install jupyter notebook and use it in vscode in conjunction with the python extension:
pdm add notebookor so to install notebook
- Add a
.envfile inside of your project director with contents like the following:
If the above still doesn't work, it's most likely because the environment variable is not properly loaded when the Notebook starts. There are two workarounds.
code .in Terminal. It will open a new VSCode window in the current directory with the path set correctly. Use the Jupyter Notebook in the new window
- If you prefer not to open a new window, run the following at the beginning of your Jupyter Notebook to explicitly set the path:
In addition, there is a VSCode Task Provider extension available for download.
Awesome PDM is a curated list of awesome PDM plugins and resources.