VSCode + debugging + poetry
See original GitHub issueHi,
we use poetry and I like to use my poetry scripts as entry points for the debugging in vscode. Therefore, we use following vscode launch.json configurations:
{
"configurations": [
{
"name": "poet_####",
"type": "python",
"request": "launch",
"module": "poetry",
"subProcess": true,
"args": [
"run",
"###name###",
],
"console": "integratedTerminal",
"justMyCode": true,
"cwd": "${workspaceFolder}",
"envFile": "",
"env": {},
},
]
}
The issue is that the debugging starts BUT exits early (after some seconds). In the middle of the process, everything stops. This is the case for all our code which is run via poetry.
If we run the python code manually without the poetry run
command, but in a poetry shell with python main.py
, the debugging works flawlessly.
If I run in a shell manually poetry run ###name### it also works flawlessly.
In principle the debugging with poetry seems to work. It stops at breakpoints and shows error msgs etc. But as mentioned, shortly after that the whole execution stops and I am out of the debugging and the process itself.
Anyone an idea what causes the early exiting?
VSCode: 1.65.2 Poetry (systemwide): 1.1.13 Poetry python: poetry: 1.1.13 poetry-core: 1.0.8
- [ x] I have searched the issues of this repo and believe that this is not a duplicate.
- [ x] I have searched the documentation and believe that my question is not covered.
Issue Analytics
- State:
- Created a year ago
- Comments:5
I FOUND A SOLUTION 😄 🥳
Pre requirements
Poetry creates environments in a cache folder. On my OS (Manjaro), environments are created in
~/.cache/pypoetry/virtualenvs/
. These environments do not have constant names that are easy to identify. For example, my “pizzas” project, has the environment folder defined with the name “pizzas-wQgq9NEZ-py3.10”So, first of all, this needs to be resolved. We need a more consistent and specific environment path. What you have to do is find and remove the environment of your project.
In my case I run:
After that, you need to specify a new environment directory:
This will create a new
.venv
file within your project. You can ignore it with.gitignore
.Because we created a new environment, we have to install the dependencies again. Execute the following command at the root of your project:
Config
With the prerequisite fixed, you can use a configuration similar to the following:
@lucasvazq your solution solve my problems, congrats bro!!!