1

I got a bunch of environment variables set with the launchctl command:

launchctl setenv TEST /Users/JohnDoe/Test

To get the value back, I can use:

launchctl getenv TEST

However, I can't access the value of TEST from Python, using os.getenv('TEST') (or even from Bash using echo $TEST). I do know how macOS manages environment variables (the difference between launchctl and Bash environment variables, etc.) so I understand why those commands don't return the value of TEST.

My question is: is there a way to access environment variables set with launchctl, without using subprocess? Using subprocess is not a no-go, I'd just rather avoid throwing lots of processes just to get environment variables :)

filaton
  • 2,257
  • 17
  • 27
  • And you are unable to start the python interpreter in a way that the required environment variables are available to the process? – languitar Mar 13 '17 at 14:19
  • Possible duplicate of [Strange behaviour for setenv & getenv in OS X Yosemite](http://stackoverflow.com/questions/27045137/strange-behaviour-for-setenv-getenv-in-os-x-yosemite) – Nils Werner Mar 13 '17 at 14:21
  • @NilsWerner thanks for pointing me to this other issue. I do use the "Reopen windows when logging back" and not planning to stop doing so. So that explains why I can't access the environment variables. I will probably switch to regular Bash variables in that case! – filaton Mar 13 '17 at 14:25

0 Answers0