A bit of a random problem here. I set an environment variable using PowerShell like this:
$env:GOOGLE_ELEVATION_API="the_api-key"
Then in python I attempt to read it with this simple script:
from os import environ
key = environ.get("GOOGLE_ELEVATION_API")
This returns None. If I query my environment variables in PowerShell it is there. If I query it through python with os.environ it is not.
None of the results I found make reference that this should be an issue, neither on the PowerShell side nor on python's side. I have not restarted my machine since I honestly do not believe this is what should be done. I did restart my IDE in the hope that it is somehow caching the environment but thankfully it does not.
Any pointers would be great!
$env:<- only affects current runspace. Will you be running the scripts in the same user context, or do you need a machine-wide env var?$env:FOO = 'bar'; Start-ThreadJob { $env:FOO } | Receive-Job -Wait -AutoRemoveJob- perhaps that's what you meant, but note that a single process can host multiple PowerShell runspaces). A regularly invoked Python script would automatically inherit the calling PowerShell session's environment variables.pythonis not launched by powershell :-)