Rocketq
Rocketq

Reputation: 5791

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

Upvotes: 5

Views: 9214

Answers (1)

Rocketq
Rocketq

Reputation: 5791

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

Upvotes: 14

Related Questions