zoukankan      html  css  js  c++  java
  • flask报错 KeyError: <flask.cli.ScriptInfo object at 0x000001638AC164E0>

    (flask_venv) D:DjangoProjectflask_test>flask db init
    Traceback (most recent call last):
      File "c:usersdaiyongdong0520appdatalocalprogramspythonpython37Lib
    unpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "c:usersdaiyongdong0520appdatalocalprogramspythonpython37Lib
    unpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "d:virtualenvflask_venvScriptsflask.exe\__main__.py", line 7, in <module>
      File "d:virtualenvflask_venvlibsite-packagesflaskcli.py", line 966, in main
        cli.main(prog_name="python -m flask" if as_module else None)
      File "d:virtualenvflask_venvlibsite-packagesflaskcli.py", line 586, in main
        return super(FlaskGroup, self).main(*args, **kwargs)
      File "d:virtualenvflask_venvlibsite-packagesclickcore.py", line 717, in main
        rv = self.invoke(ctx)
      File "d:virtualenvflask_venvlibsite-packagesclickcore.py", line 1137, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "d:virtualenvflask_venvlibsite-packagesclickcore.py", line 1137, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "d:virtualenvflask_venvlibsite-packagesclickcore.py", line 956, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "d:virtualenvflask_venvlibsite-packagesclickcore.py", line 555, in invoke
        return callback(*args, **kwargs)
      File "d:virtualenvflask_venvlibsite-packagesclickdecorators.py", line 17, in new_func
        return f(get_current_context(), *args, **kwargs)
      File "d:virtualenvflask_venvlibsite-packagesflaskcli.py", line 425, in decorator
        with __ctx.ensure_object(ScriptInfo).load_app().app_context():
      File "d:virtualenvflask_venvlibsite-packagesflaskcli.py", line 392, in load_app
        app = locate_app(self, import_name, None, raise_if_not_found=False)
      File "d:virtualenvflask_venvlibsite-packagesflaskcli.py", line 257, in locate_app
        return find_best_app(script_info, module)
      File "d:virtualenvflask_venvlibsite-packagesflaskcli.py", line 83, in find_best_app
        app = call_factory(script_info, app_factory)
      File "d:virtualenvflask_venvlibsite-packagesflaskcli.py", line 117, in call_factory
        return app_factory(script_info)
      File "D:DjangoProjectflask_testapp\__init__.py", line 23, in create_app
        app.config.from_object(config[config_name])
    KeyError: <flask.cli.ScriptInfo object at 0x000001638AC164E0>

    报错原因:

    没有指向指向启动文件 flask_test.py

    添加一个环境变量,解决

    set FLASK_APP=flask_test.py
  • 相关阅读:
    使用transfor让图片旋转
    block与inline,inline和inline-block,块级和行内元素,行内替换和行内非替换元素
    使用classList来实现两个按钮样式的切换
    关于css透明度的问题
    级动(两级联动)思路分享
    js图片预览(一张图片预览)
    js关于密码框强弱度的提示
    javascript对象与实例
    javascript 逻辑运算符
    Raphael画圆弧
  • 原文地址:https://www.cnblogs.com/dyd520/p/11897989.html
Copyright © 2011-2022 走看看