I have recently bought a new laptop and set up VSCode and Python so I can continue coding. Everything looks fine, took a bit of messing around to get virtual environments working, but apart from that no problem EXCEPT my code does not run.
To be specific, when I open my code and click "Run | Start Debugging (F5)", for an instant the little toolbar of debug buttons (run, step-over, etc) pops up and disappears, but the code in the window does not run, there is no output to the terminal, nothing happens!
A screenshot of my entire VSCode screen is below.
My launch.json file is below.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"file": "${workspaceFolder}/web/_test/book.html"
},
{
"name": "Python: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Flask (development mode)",
"type": "debugpy",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "flask_run.py",
"FLASK_ENV": "development"
},
"args": [
"run"
],
"jinja": true
}
]
}
I have all the python extensions installed.
2
Answers
Click on python version in the lower right corner, then select switch to
python 3.12.1
in the list.For me in some virtual environments with some scripts, adding
"justMyCode": false
to the config in mylaunch.json
did actually help with this problem. Here is the documentation: https://code.visualstudio.com/docs/python/debugging#_justmycode