我正在尝试永久设置环境变量。 但暂时可以正常工作。
I am trying to set a environmental variable permanently. but temporarily it is working.
如果我在程序下面运行,我得到了可变路径。 关闭它并打开新终端后,使用命令 `printenv LD_LIBRARY_PATH` 查找变量路径,将不会打印任何内容。
if i run below program i got the variable path. after close it and open new terminal to find the variable path using the command `printenv LD_LIBRARY_PATH` nothing will print.
#!/usr/bin/python
import os
import subprocess
def setenv_var():
env_var = "LD_LIBRARY_PATH"
env_path = "/usr/local/lib"`enter code here`
os.environ[env_var] = env_path
process = subprocess.Popen('printenv ' + env_var, stdout=subprocess.PIPE, shell=True)
result = process.communicate()[0]
return result
if __name__ == '__main__':
print setenv_var()
请帮助我。
please help me.