问题
I am new to python and encountering some issues while executing os commands.
I have set my environment variables
like as shown below
SPARK_HOME = '/opt/spark'
HAIL_HOME = '/opt/hail/hail'
When I type os.getenv('SPARK_HOME')
, I get the below output
'/opt/spark/'
But when I type os.getenv('HAIL_HOME')
, I get blank output
Please note that I type the above two commands from a virtual environment using jupyter notebook.
- Why it works for
spark
and returns empty forhail
Can guide me with this issue?
回答1:
Based on our discussion on chat, identified several issues.
Variable setting is confused with env variable setting. So correct way to set them should be like:
os.putenv('SPARK_HOME', '/opt/spark')
os.putenv('HAIL_HOME', '/opt/hail/hail')
Even the mistaken env variable set attempts, SPARK_HOME shows the correct value because jupyter process inherits that variable from the shell.
来源:https://stackoverflow.com/questions/62530145/os-getenv-returns-empty-output-python