python os操作环境变量,无法使用OS Python获取环境变量

I recently created two environment variables in my terminal as shown below

export SPARK_HOME='/opt/spark/'

export HAIL_HOME='/home/ABCD/.pyenv/versions/3.7.2/envs/bio/lib/python3.7/site-packages/hail/'

When I use echo $SPARK_HOME or echo $HAIL_HOME, I am able to see the path as output

But, when I use the below os commands in jupyter notebook

os.getenv('SPARK_HOME') # able to get the output /opt/spark/

os.getenv('HAIL_HOME') # returns no output

I also tried defining the same variables from jupyter as well using os.putenv but even then,I see output only for SPARK_HOME

However, I am able to see in my terminal screen the environment variablesSPARK_HOME and HAIL_HOME using printenv command

Can help me understand what's the problem?

解决方案

I realized that it doesn't produce output for HAIL_HOME because it is installed in my virtual environment. (see .pyenv which is a hidden folder for my virtual environment`)

However, if anyone can confirm this it's even better

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值