Reputation: 2499
This question is related to this question about conda, and it is pretty straightforward:
How can I use an external environment variable inside launch.json
?
For instance, selecting the python executable inside my home with $HOME
, or the executable:
{
"name": "Python: From Home",
"type": "python",
"request": "launch",
"program": "$HOME/Documents/a.py", // nor does "${HOME}" work
"console": "internalConsole",
"cwd": "${workspaceFolder}"
}
or
{
"name": "Python: With Anaconda",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "internalConsole",
"python": "${HOME}/anaconda3/bin/python3",
"cwd": "${workspaceFolder}"
}
This would simplify sharing launch.json
with coworkers.
Upvotes: 12
Views: 44908
Reputation: 17912
You can use the attribute "env"
in settings.json
. For example:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
// ENVINRONMENT VARIABLES
"env": {
"VAR_A": "value_a",
"VAR_B": "value_b"
}
}
]
}
Upvotes: 4
Reputation: 28783
You can use Environment variables
The syntax is like ${env:USERNAME}
Upvotes: 7