Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python os library does not see environment variables in Windows

As you can see on the picture below, I have 'SPARK_HOME' environment variable:

enter image description here

However I just can't get it through python:

import os
os.environ.get('SPARK_HOME', None)  # returns None
"SPARK_HOME" in os.environ          # returns False

What am I doing wrong? Operating system is Windows 7 PS: I can get other variables, for example:

spark_home = os.environ.get('PYTHONPATH', None)
print spark_home  # returns correct path
like image 374
Rocketq Avatar asked Feb 06 '23 02:02

Rocketq


1 Answers

To get your python start seeing new variables you need to restart your console, not just only ipython notebook!!!

like image 117
Rocketq Avatar answered Feb 08 '23 14:02

Rocketq