I have set some environment variables in ~/.profile:
SOMEVAR=/some/custom/path
and already did source ~/.profile. So when I do:
echo $SOMEVAR
it prints the correct directory:
/some/custom/path
However, when I try to read this variable in a Python script, it fails:
import os
print(os.environ["SOMEVAR"])
I get:
Traceback (most recent call last):
File "environment_test.py", line 3, in <module>
print os.environ["SOMEVAR"]
File "/usr/lib64/python2.7/UserDict.py", line 23, in __getitem__
raise KeyError(key)
KeyError: 'SOMEVAR'
What's wrong there?