As you can see on the picture below, I have 'SPARK_HOME' environment variable:
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
asked Sep 20, 2016 at 12:27
Rocketq
5,84124 gold badges86 silver badges138 bronze badges
1 Answer 1
To get your python start seeing new variables you need to restart your console, not just only ipython notebook!!!
answered Sep 20, 2016 at 12:36
Rocketq
5,84124 gold badges86 silver badges138 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
lang-py
WM_SETTINGCHANGEmessage to top-level windows. Explorer see this message and reloads its environment from the registry values; it's pretty much the only program that looks for this message. Console programs generally don't even own any windows. You need to start a new instance of cmd.exe or python.exe with Explorer as the parent, so it will inherit the updated environment.WM_SETTINGCHANGEand updates also its own environment variable list which contains also some Total Command related environment variables. That can be seen on startingcmd.exefrom within Total Commander and runset. Then a user or system environment variable is added/modified using Windows System Control Panel and after closing Environment Variables dialog window with button OK, one morecmd.exeis started from within Total Commander andsetis executed also in this second command process instance. The added/modified variable is shown in second cmd.