Ich habe ein Python-Skript, das den Wert der Umgebungsvariablen $ UID kennen muss. Das Problem ist, dass diese Variable aus irgendeinem Grund nicht in os.environ
existiert.UID env-var wird nicht in Pythons 'os.environ' dict kopiert
Unten ist eine interaktive Demonstration - die $ UID ist in der Shell definiert, aber obwohl Python von derselben Shell aus gestartet wird, existiert die Umgebungsvariable 'UID' nicht in os.environ
.
Ist es ein bekanntes Problem? Gibt es etwas zu tun?
$ 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'
>>>