I'm using pyenv
. The environment is created with these commands:
pyenv install 3.6.0
pyenv virtualenv 3.6.0 foo
pyenv local foo
python my_app.py
In the application I want to load some environment variables with this command:
SOME_VARIABLE = environ.get('MY_ENV_VAR', None)
The problem is, that although MY_ENV_VAR
is set with export MY_ENV_VAR=test
(and I can display its content with echo $MY_ENV_VAR
), the python code reads no value.
So how can this be done correctly?
echo $MY_ENV_VAR
andpython -c "import os; print(os.environ.get('MY_ENV_VAR'))"
; do both print "test"? – Palliativepyenv shell
? This gives "no shell-specific version configured". @Palliative echoing the variable returns its true content, priting it in python like this prints "None". – Gamesmanship