LeetaoGoooo/peach-blog

flask shell报错,请问如何解决?

Closed this issue · 2 comments

$ flask shell
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "c:\programdata\anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\ProgramData\Anaconda3\Scripts\flask.exe_main
.py", line 7, in
File "c:\programdata\anaconda3\lib\site-packages\flask\cli.py", line 966, in main
cli.main(prog_name="python -m flask" if as_module else None)
File "c:\programdata\anaconda3\lib\site-packages\flask\cli.py", line 586, in main
return super(FlaskGroup, self).main(*args, **kwargs)
File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\programdata\anaconda3\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\programdata\anaconda3\lib\site-packages\click\decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\programdata\anaconda3\lib\site-packages\flask\cli.py", line 425, in decorator
with _ctx.ensure_object(ScriptInfo).load_app().app_context():
File "c:\programdata\anaconda3\lib\site-packages\flask\cli.py", line 392, in load_app
app = locate_app(self, import_name, None, raise_if_not_found=False)
File "c:\programdata\anaconda3\lib\site-packages\flask\cli.py", line 240, in locate_app
import(module_name)
File "C:\Users\panxi\Desktop\peach-blog\wsgi.py", line 3, in
application = create_app(os.environ.get('FLASK_ENV'))
File "C:\Users\panxi\Desktop\peach-blog\app_init
.py", line 33, in create_app
app.config.from_object(config[config_name])
KeyError: None

@evertears 看错误信息应该是没有设置 FLASK_ENV 这个变量

在命令行下

# linux | mac
export FLASK_ENV=development
# windows
set FLASK_ENV=development

logs和posts文件夹需要自己单独创建否则运行报错找不到目录,已经成功运行了,非常感谢大神。