By default the run button always runs the file you’re currently viewing, and it’s annoying because most of the time I don’t want that: I’ll be editing another file and then want to run my main.py file, so instead I have to go in the main file and then execute it. How can I change this?
I tried looking online but couldn’t find anything useful.
Question posted in Visual Studio Code
View the official documentation.
View the official documentation.
2
Answers
Create a launch.json file in the Run and Debug panel, and then replace the configuration
"program": "${file}",
with"program": "./main.py",
.File structure
launch.json
Then select
Run Without Debugging
, or use the shortcut key Ctrl+F5to run the code.enter image description here
In here, may have several python terminals. Close all and compile again.