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?
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'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With