【发布时间】:2018-06-24 12:58:15
【问题描述】:
我在 python 脚本中设置 linux os 环境变量。好像没有正确设置。
使用的代码:
import os
from subprocess import call
squid_server_ip = 1.1.1.1
os.chdir("somepath")
call(["pwd"])
os.environ["LD_LIBRARY_PATH="] = ".:$LD_LIBRARY_PATH"
print os.environ['LD_LIBRARY_PATH']
call(["./DUModifier","-httpproxy", "{}:3128".format(squid_server_ip)])
输出:
somepath
/export-path
./DUModifier: error while loading shared libraries: xBase39.so: cannot open shared object file: No such file or directory
手动执行:
cd somepath
export LD_LIBRARY_PATH=.:$LD_LIBRARY
echo $LD_LIBRARY_PATH
.:.:/export-path
./DUModifier -httpproxy 1.1.1.1:3128
DUModifier Release2.1 2018-01-16T04:07:57-05:00
Configuration file to modify: xgDeployConfig.xml
New configurations are:
Option: httpproxy, value: 1.1.1.1:3128
Successfully modified config file: xgDeployConfig.xml
谁能帮我解决一下
【问题讨论】:
-
感谢您指出我使用了 like os.environ["LD_LIBRARY_PATH"] = ".:$LD_LIBRARY_PATH"..然后它工作正常
-
除非我误解(这很有可能),否则不,它确实不工作正常:这有多个问题 - 请参阅下面的答案。
标签: python linux python-2.7 unix