简体   繁体   中英

The environment variable is not set

I use environment variable to pass settings file:

app.config.from_envvar('DVR_SETTINGS')

It works fine on my dev system but when I try to deploy this thing on embedded linux system (arago) I get this:

RuntimeError: The environment variable 'DVR_SETTINGS' is not set and as such configuration could not be loaded.
Set this variable and make it point to a configuration file

But I have done it:

root@dm365-evm:/var/www/dvr# echo $DVR_SETTINGS
/var/www/dvr/settings/production.py

You need to export the environment variable:

export DVR_SETTINGS

You can combining setting and exporting in one line:

export DVR_SETTINGS=/var/www/dvr/settings/production.py

or you can put it on the line running your Flask server:

DVR_SETTINGS=/var/www/dvr/settings/production.py python flask_script.py

In OS windows you need to export the environment variable:

  • print(os.environ) you can see a list of all environment
  • set "environment variable"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM