在pycharm中设置环境变量?

问题描述 投票:0回答:1

我想学习flask,并为此创建了一个小程序。当我尝试运行它时,我得到了以下错误。flask run 错误-

* Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
Usage: flask run [OPTIONS]

Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.

如果我尝试将文件名改为 app.py 顺利运行,但当文件名为 flaskblog.py 它不工作。

我试着按照blog-&gt中的建议设置环境变量。如何在PyCharm中设置环境变量? 中的建议设置环境变量,但没有任何效果。

附上截图。环境变量文件的内容

shows envfile option is checked under flaskblog configuration

environment variable at project level

at python console level

os.environ['FLASK_APP'] output

python pycharm environment-variables
1个回答
0
投票

我能够通过在终端上设置环境变量来解决这个问题。set FLASK_APP=flaskblog.py

然后它就像顺利地运行了。

© www.soinside.com 2019 - 2024. All rights reserved.