在python os.environ中无法看到LD_LIBRARY_PATH

时间:2017-03-07 08:49:47

标签: python

在python中遇到LD_LIBRARY_PATH问题。我无法在python解释器中得到它。我正在使用python:

$ Python 2.6.6 (r266:84292, Jul 22 2015, 16:47:47)[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2

>>> import os
>>> print os.environ['LD_LIBRARY_PATH']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/UserDict.py", line 22, in __getitem__
raise KeyError(key)
KeyError: 'LD_LIBRARY_PATH'

但是在shell中,LD_LIBRARY_PATH的值为:

echo $LD_LIBRARY_PATH
/var/test/lib

不知道为什么忽略LD_LIBRARY_PATH?

当我手动导出测试变量'MY_TEST'时,我可以看到它

$exprot MY_TEST=/var/
>>> print os.environ['MY_TEST']
/var/

但是如果我导出LD_LIBRARY_PATH:

    $export LD_LIBRARY_PATH=/var
     >>> print os.environ['LD_LIBRARY_PATH']
     Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/usr/lib64/python2.6/UserDict.py", line 22, in __getitem__
     raise KeyError(key)
     KeyError: 'LD_LIBRARY_PATH'

有人知道为什么吗?

0 个答案:

没有答案