Okay, first of all: I am new to VSC and Python. I developed 20 years with VBA mainly, and this is my first project that I am trying to do with Python.
I have installed Python and Visual Studio Code (VSC), installed Python extensions for VSC and Postman. Now I want to run my project by hitting Ctrl + F5
.
The Terminal shows all messages as if I typed python main.py
, but when I am checking the first microservice at localhost:8001
, it says it is unable to connect. Running the project by typing python main.py
produces the same export, but I am able to connect to localhost:8001
and other microservices.
From what I read, I am supposed to have a launch.json
file, that should encompass all run and debug configurations. My launch.json
looks like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: main.py",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}\main.py",
"console": "integratedTerminal"
}
]
}
Aside from the fact that the editor is recommending to replace "python"
with "debugpy"
, nothing changed the behaviour described above. I read somewhere that VSC is “automagically” deciding, whether you are running a project witout or with debug and that the user has just to have a configuration for the debug case. But this sounds all … special … to me.
I also tried something that a friend recommended with a "compounds"
section in launch.json, but neither did I understand, why I should do that, nor did it solve anything. 😛
Okay, long story short:
- What should my
launch.json
look like. - Is there a way to automatically start the virtual environment of a project when hitting (Ctrl + ) F5?
- How can I test – maybe with a minimal working example – whether I found the correct
launch.json
? - Do you have other tips that would help me finding my way? 😉
Thank you very much in advance!