I added a few environment variables to my activate script by adding
export MYVAR=blahblah
to the end.
When I activate via source ./activate
and then do printenv
I see them.
From a bash terminal if I launch python then do
import os
os.environ
then I see them.
BUT if I open a jupyter notebook either through the web interface or through VSC remote connection then I don't see them.
What's the missing link?
I'm not sure why the environment variables set in the activate script don't persist to a notebook session but I found that using kernel startups does what I need.
Specifically I used dot-env and the ipython kernel startup folder.
I made a 2 line script in ~/.ipython/profile_default/startup
which just says
from dotenv import load_dotenv
load_dotenv()
and saved it as 00_make_envs.py in that folder
Also, I made an .env
file in that same folder that has all the environment variables I want to use, it's in the same format that docker uses... ie
MYVAR1=blahblah
MYVAR2=foobar