I have a Python script that needs to know the value of the $UID environment variable. The problem is, that for some reason, this variable does not exist in os.environ
.
Below is an interactive demonstration - the $UID is defined on the shell, but although Python is launched from the same shell, the 'UID' environment variable does not exist in os.environ
.
Is it a known problem? Is there anything to do about it?
$ echo $UID
1003
$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['UID']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__
raise KeyError(key)
KeyError: 'UID'
>>>