Reputation: 40186
I have an environment variable that I can print from the terminal:
echo $STATTLE_TOKEN
returns
"ALKJSLKJLKFJALSKJFLASJFLSAF"
When I am in ipython, I can print it using:
import os
os.getenv("STATTLE_TOKEN")
which prints
"ALKJSLKJLKFJALSKJFLASJFLSAF"
However when I fire up a new Rstudio session,
Sys.getenv("STATTLE_TOKEN")
yields
""
What am I missing? I want to leverage my system's environment variables, but obviously I am not connecting the dots onto something. I would prefer not to have to put it in a file that loads on startup for my project.
Thanks in advance.
Upvotes: 5
Views: 4024
Reputation: 368629
You probably start your interactive Python differently from your RStudio session. The outcome suggests that iPython may be a child process -- maybe you launched it from the shell?
The key will be to make R(Studio) aware of these environment variables. You could always set them explicitly in ${R_HOME}/etc/Renviron.site
.
Upvotes: 5