Running some v basic scripts with environment variables so I don’t have to hard code things like my api key or id. My code wouldn't run and was failing on authorising so either my id and/or key didn't work. So I just printed out the variables to see where it died.
import os
user = os.getenv('USER')
tempLocation = os.getenv('TEMP')
Id = os.getenv('MY_ID')
Key = os.getenv('MY_KEY')
print(user)
print(tempLocation)
print(Id)
print(Key)
But I’m getting different responses depending on where the code is run. My output is below, the id and key have been altered for here but they are returning info. From WSL terminal I’m only retuning my user name:
me
None
None
None
But if I use the Jupyter interactive terminal in VS Code I get:
None
C:\Users\me\AppData\Local\Temp
xxxxxx
1234567890abcdefg
I'd prefer to be able to just run the script from my WSL terminal cos that's quicker for things to run in the future, but without the env getting keys/site ID it's a bit of a pain.