P
Peng Yu
Hi,
R_HOME is set in my shell (bash). But os.environ doesn't have it. I'm
not sure what it does when os module is imported. But it seems that
os.environ doesn't capture all the environment variable from the
shell. Could anybody let me know what is the correct way to inherent
all the environment variables form the shell?
$ echo $R_HOME
/opt/R-2.11.1
$ cat main.py
#!/usr/bin/env python
import os
print os.environ['R_HOME']
$ ./main.py
Traceback (most recent call last):
File "./main.py", line 5, in <module>
print os.environ['R_HOME']
File "/opt/Python-2.6.5/lib/python2.6/UserDict.py", line 22, in __getitem__
raise KeyError(key)
KeyError: 'R_HOME'
R_HOME is set in my shell (bash). But os.environ doesn't have it. I'm
not sure what it does when os module is imported. But it seems that
os.environ doesn't capture all the environment variable from the
shell. Could anybody let me know what is the correct way to inherent
all the environment variables form the shell?
$ echo $R_HOME
/opt/R-2.11.1
$ cat main.py
#!/usr/bin/env python
import os
print os.environ['R_HOME']
$ ./main.py
Traceback (most recent call last):
File "./main.py", line 5, in <module>
print os.environ['R_HOME']
File "/opt/Python-2.6.5/lib/python2.6/UserDict.py", line 22, in __getitem__
raise KeyError(key)
KeyError: 'R_HOME'