烧瓶运行在设置FLASK_APP之后出现错误

时间:2020-01-08 13:01:41

标签: python flask

在运行flask时,它运行良好,直到未设置FLASK_APP变量,但是当我设置error变量时它会给出FLASK_APP

错误代码附在下面。

(venv) (base) C:\Users\Desktop\Python\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
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

(venv) (base) C:\Users\Desktop\Python\Flask>echo %FLASK_APP%
%FLASK_APP%

(venv) (base) C:\Users\Desktop\Python\Flask>set FLASK_APP=Flask.py

(venv) (base) C:\Users\Desktop\Python\Flask>echo %FLASK_APP%
Flask.py

(venv) (base) C:\Users\Desktop\Python\Flask>flask run
 * Serving Flask app "Flask.py"
 * 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: While importing "Flask", an ImportError was raised:

Traceback (most recent call last):
  File "c:\users\desktop\python\flask\venv\lib\site-packages\flask\cli.py", line 240, in locate_app
    __import__(module_name)
  File "C:\Users\Desktop\Python\Flask\Flask.py", line 1, in <module>
    from .app import app, db
ImportError: attempted relative import with no known parent package


(venv) (base) C:\Users\Desktop\Python\Flask>

此外,如果未设置FLASK_APP变量,flask如何能够识别要运行的python文件?

0 个答案:

没有答案