scons "import os" 没有导入我的 OS 环境变量?
scons "import os" is not importing my OS environment variable?
我正在 MAC 上测试 scons 的行为,我尝试 "import os" 从环境变量构建,如下所示:
$cat SConstruct
import os
env=Environment(ENV=os.environ)
kkk=env['MY']
然后我尝试运行它,似乎仍然没有通过"env=Environment(ENV=os.environ)"语句
导入环境变量
$export MY='haha'
$/usr/local/bin/scons
scons: Reading SConscript files ...
KeyError: 'MY':
File "/Users/my/SConstruct", line 3:
kkk=env['MY']
File "/usr/local/Cellar/scons/2.5.1/libexec/scons-local/SCons/Environment.py", line 410:
return self._dict[key]
我使用的是 scons 版本:
$/usr/local/bin/scons -v
SCons by Steven Knight et al.:
script: v2.5.1.rel_2.5.1:3735:9dc6cee5c168[MODIFIED], 2016/11/03 14:02:02, by bdbaddog on mongodog
engine: v2.5.1.rel_2.5.1:3735:9dc6cee5c168[MODIFIED], 2016/11/03 14:02:02, by bdbaddog on mongodog
engine path: ['/usr/local/Cellar/scons/2.5.1/libexec/scons-local/SCons']
Copyright (c) 2001 - 2016 The SCons Foundation
我哪里做错了,如何解决?
尝试:
import os
env=Environment(ENV=os.environ)
my_env_value=env['ENV']['MY']
SCons 提供给命令 运行 的环境是 env['ENV'],而不是 env 本身。
我正在 MAC 上测试 scons 的行为,我尝试 "import os" 从环境变量构建,如下所示:
$cat SConstruct
import os
env=Environment(ENV=os.environ)
kkk=env['MY']
然后我尝试运行它,似乎仍然没有通过"env=Environment(ENV=os.environ)"语句
导入环境变量$export MY='haha'
$/usr/local/bin/scons
scons: Reading SConscript files ...
KeyError: 'MY':
File "/Users/my/SConstruct", line 3:
kkk=env['MY']
File "/usr/local/Cellar/scons/2.5.1/libexec/scons-local/SCons/Environment.py", line 410:
return self._dict[key]
我使用的是 scons 版本:
$/usr/local/bin/scons -v
SCons by Steven Knight et al.:
script: v2.5.1.rel_2.5.1:3735:9dc6cee5c168[MODIFIED], 2016/11/03 14:02:02, by bdbaddog on mongodog
engine: v2.5.1.rel_2.5.1:3735:9dc6cee5c168[MODIFIED], 2016/11/03 14:02:02, by bdbaddog on mongodog
engine path: ['/usr/local/Cellar/scons/2.5.1/libexec/scons-local/SCons']
Copyright (c) 2001 - 2016 The SCons Foundation
我哪里做错了,如何解决?
尝试:
import os
env=Environment(ENV=os.environ)
my_env_value=env['ENV']['MY']
SCons 提供给命令 运行 的环境是 env['ENV'],而不是 env 本身。