Reputation: 2124
I've set the environment variable in the shell like this
export DEPLOY=development
and running this returns "development"
echo $DEPLOY
However... this returns none in python.
import os
os.environ.get("DEPLOY")
and this raises a key error
os.environ["DEPLOY"]
I've deleted the .pyc files and restarted my IDE...
Any ideas?
Upvotes: 0
Views: 1756
Reputation: 295272
export DEPLOY=development
only changes the environment for your shell, and programs that shell starts.
Because you're starting Python from your IDE, not from the shell, the Python interpreter is not a child (or grandchild) process of that shell, and so does not inherit the shell's environment variables.
Upvotes: 1