I am stuck on an environment variables mismatch.
I run a Python script on Windows 10 via a program called NSSM.
At runtime, I do the following:
os.environ.setdefault(name, value)
.os.environ[name]
Result:any variables I added do not show up.
I am not sure why the variables I add aren't available. Can you please tell me what I am doing wrong?
A starting point is that NSSM uses environment variables from Windows HKLM registry: source (see bottom). I am not sure if this is the reason os.environ
cannot see relevant variables.
Well it turns out that my problem was outside of the scope of this question. @Recessive and @eryksun thank you both for answering, it put me "onto the scent".
It turns out my problem was using Python pathlib's Path.home()
.
HOMEPATH
environment variable.USERPROFILE
environment variable.This discrepancy in Path.home()
was the real problem. It wasn't finding the environment variables because NSSM was looking in a totally different folder.