os.environ doesn't show all environmental variables in Jupyter notebook
10,638
You can query all the dictionary keys to confirm the one you have is not there.
import os
print(os.environ.keys())
Or better you can test for the presence of the specific key.
print(os.environ.has_key('STUFF'))
Author by
helloB
Updated on July 21, 2022Comments
-
helloB almost 2 years
I am finding that the following code prints out my expected environmental variable when I execute the script in a shell:
import os print(os.environ['STUFF'])
However, when I run this same code in Jupyter Notebook, I get a key error. I have tried restarting the Jupyter server. What else should I do?
-
tdelaney over 7 yearsThe key error already confirms that the key isn't there. This may be useful as a comment but doesn't answer the question.