1

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?

The Great
  • 7,215
  • 7
  • 40
  • 128

2 Answers2

1

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

The Great
  • 7,215
  • 7
  • 40
  • 128
0

use os.environ.get("SPARK_HOME").

Devendra Mishra
  • 77
  • 3
  • 10
  • Sorry, my question is on why doesn't it work for `HAIL_HOME`? When I type `os.environ.get("HAIL_HOME")`, I get blank/no output – The Great Jun 24 '20 at 16:21
  • *** Works for both env may be you have to see some process not overriding your exisiting environment variable.* – Devendra Mishra Jun 24 '20 at 16:26