I'm trying to do a basic thing: debug a python function app using a virtual environment.
The Visual Studio code documentation does not indicate how to do and I cannot figure it out myself: https://code.visualstudio.com/docs/python/debugging
I run the app from the terminal with the following command:
.venv36\scripts\activate
func start
The app is run from my virtual environment and everything is OK.
To debug, the debugger uses the launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Python Functions",
"type": "python",
"request": "attach",
"port": 9091,
"windows": {
"pythonPath": ".venv36\\Scripts\\python.exe"
},
"preLaunchTask": "func: host start"
}
]
}
Reading the https://code.visualstudio.com/docs/python/environments, I added the following settings to the settings.json:
{
...
"python.pythonPath": ".venv36\\Scripts\\python.exe",
"python.pipenvPath": ".venv36\\Scripts\\pip.exe",
"python.venvPath": ".venv36",
"python.terminal.activateEnvironment": true,
The tasks.json is:
{
"version": "2.0.0",
"tasks": [
{
"type": "func",
"command": "host start",
"problemMatcher": "$func-watch",
"isBackground": true,
"options": {
"cwd": "${workspaceFolder}/AlarmScoringFuncApp"
}
}
]
}
When I start debugging, the app is started but not in the right environment: it is using the system libraries instead of the ones installed for my project in the requirements.txt.
My app crash when it tries to use a library that is not installed in the system environment.