代码改变世界

Windows下Flask run报错'Could not locate flask application' 原因?

2018-08-09 20:53  菜鸟Alex  阅读(13667)  评论(0编辑  收藏  举报
  • 运行环境Windows系统, 命令行工具powershell

  • 执行如下命令报错:

    1. 设置set FLASK_APP = run.py
    2. 运行flask run
  • 报错如下: Flask找不到上面设置的应用,或者说找不到运行脚本run.py而报出: Error: Could not locate flask application. You did not provide the FLASK_APP environment variable

  • 具体原因不清楚,不过找到了解决方案,将下面命令替换set FLASK_APP = run.py$env:FLASK_APP = "run.py"


参考自Stack Overflow: https://stackoverflow.com/questions/37826016/env-variables-not-set-while-running-minimal-flask-application

问题:

解决方案: