In my VS Code settings.json
file, I can use the following option to define environment variables:
"terminal.integrated.env.osx" : {
"MY_ENV": "test"
"MY_ENVTYPE": "qa"
}
Now whenever, I start a new shell in the workspace, the shell loads with the above environment variables, and I can access them typically with os.environ["MY_ENV"]
is my python scripts.
But with the same settings.json
, if I try to access the environment variables in a Nupyter Notebook I get None
. So my question is, is there a way to define environment variables in VS Code's settings.json
file, so whenever I start a new notebook, the environment variables are loaded by default.
Currently the workaround I have found is to add the following code snippet in a top code cell.
import os
os.environ["MY_ENV"] = "test"
os.environ["MY_ENVTYPE"] = "qa"
I am hoping there is a better way to do the same thing.