python – Recovery of environment variables in Ubuntu or macOS

The brief bonjour.py

bone import
Flask bottle import
from dotenv import load_dotenv

app = Bottle (__ name__)
dotenv_path = os.path.join (os.path.dirname (__ file__), & # 39; .env)
load_dotenv (dotenv_path)


@ app.route (& # 39;)
def index ():
SECRET_KEY = os.environ.get ("SECRET_KEY")
DATABASE_PASSWORD = os.environ.get ("DATABASE_PASSWORD")
returns SECRET_KEY + DATABASE_PASSWORD + os.linesep

takes his environment from one .env file

export FLASK_APP = / home / ubuntu / difficult /
export SECRET_KEY = ABCD
export DATABASE_PASSWORD = EFGH

After launching the server (using either balloon race or gunicorn), asking curl localhost: 8000 reports the planned ABCDEFGH, the two env-vars picked up from .env.

Until here everything is fine.

Now we ask supervisor launch bonjour.py for us

[program:hello]



command = / home / ubuntu / venv / bin / gunicorn -b localhost: 8000 hello: app
directory = / home / ubuntu / difficult /
user = ubuntu
stdout_logfile = / home / ubuntu / ough / logs / hello_out.log
stderr_logfile = / home / ubuntu / ough / logs / hello_err.log
autostart = true
autorestart = true
stopasgroup = true
killasgroup = true

[supervisord]
log file = / home / ubuntu / difficult / logs / hello-supervisord.log
pidfile = / home / ubuntu / robust / supervisord.pid

Everything goes perfectly on MacOS (High Sierra). Both environment variables are well taken into account. But on Ubuntu (18.04) I get

File "/home/ubuntu/tough/hello.py", line 14, in the index
returns SECRET_KEY + DATABASE_PASSWORD + os.linesep
TypeError: Operand type (s) not supported for +: & # 39; NoneType & # 39; and & # 39; NoneType & # 39;

What could be the difficulty of capturing env-vars on Ubuntu, an event that does not appear on Darwin?