Debugging a PDM-managed project in VSCode #376
pawamoy
started this conversation in
Show and tell
Replies: 1 comment 2 replies
-
Thanks for the showcase! :-) After setting up VS Code for PDM as described in the current docs, I did not have to use any additional setup to get debugging and even running tests from the sidebar working. So no need for specialized launch configurations :-) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I had a bit of trouble setting up VSCode to be able to debug my code and add breakpoints onto the libraries installed in
__pypackages__
, so here is a how to.First, know that I installed PDM with pipx:
It used my system Python, which is
/usr/bin/python
, and is version 3.9.If I wanted to use another version, I would have installed it like this:
Then I set up my project to use Python 3.9 and installed the libraries:
cd myproject pdm use -f 3.9 pdm install -d
My code lives in the
src
folder.In VSCode, I defined the Python interpreter to
/usr/bin/python
.I then added a Run configuration which sets the
PYTHONPATH
environment variable so Python can find both my code and the libraries in__pypackages__
..vscode/settings.json
.vscode/launch.json
If you set up a different Python interpreter, make sure you set the
env
accordingly. For example with a Python 3.8 interpreter, add__pypackages__/3.8/lib
to the Python path.Beta Was this translation helpful? Give feedback.
All reactions