[Flask] env variable not set

Robinson Collado robinsoncollado at gmail.com
Tue Aug 11 20:14:39 CEST 2015


Environmental variable are read through a command prompt. So if you want to
set the variable "APP_CONFIG_FILE" you would have to type the following
into a command prompt before running your program:

On Linux or Max OSX:
export APP_CONFIG_FILE = "path_to_file"

On Windows:
set APP_CONFIG_FILE = "path_to_file"

I would suggest for you to read this
<http://stackoverflow.com/questions/4906977/how-to-access-environment-variables-from-python>
to
learn how to properly access the content in the environmental variable.

Though, I believe that you're looking to load the config from a file. Then
this <http://flask.pocoo.org/docs/0.10/config/#configuring-from-files> should
clear things up.


On Tue, Aug 11, 2015 at 7:14 PM, west alto <westalto at gmail.com> wrote:

> Hi Gurus,
>
> Noob here. It makes me nuts figuring this out. Kindly help.
>
>
>    1. import os
>    2.
>    3. from flask.ext.script import Manager
>    4. from api import api
>    5.
>    6.
>    7. manager = Manager(api)
>    8.
>    9.
>    10. def runserver():
>    11.     api.run()
>    12.
>    13.
>    14. if __name__ == '__main__':
>    15.     root_dir = os.path.abspath(os.path.dirname(__file__))
>    16.     os.environ["APP_CONFIG_FILE"] = os.path.join(root_dir,
>    'env/dev.py')
>    17.     manager.run()
>
>
> running python manage.py runserver gives me this error
>
> RuntimeError: The environment variable 'APP_CONFIG_FILE' is not set and as
> such configuration could not be loaded.  Set this variable and make it
> point to a configuration file
>
>
> Thanks,
>
> West
>
>
>
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
>
>


-- 
Robinson Collado
Web Developer - robinsonc.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20150811/16db69c4/attachment.html>


More information about the Flask mailing list