我试图在anaconda提示符下运行下面的烧瓶应用程序
from flask import Flask, flash, redirect, url_for, render_template, request, session, abort
import os
from wtforms import Form, TextField, TextAreaField, validators, StringField, SubmitField
from werkzeug import secure_filename
app = Flask(__name__)
app.config.from_object(__name__)
app.run(debug=True)
@app.route('/')
@app.route("/index", methods=['GET', 'POST'])
def index():
if request.method == 'POST':
return render_template('map.html')
else:
return render_template('map.html')
if __name__ == "__main__":
app.secret_key = os.urandom(12)
app.run(debug=True,host='0.0.0.0', port=4000)
这将导致以下错误:
(C:\Users\jgpfi_000\Anaconda3)
C:\Users\jgpfi_000\Documents\housescrapeapp>py app_index.py
Traceback (most recent call last):
File "app_index.py", line 3, in
from flask import Flask, flash, redirect, url_for, render_template, request, session, abort
ModuleNotFoundError: No module named 'flask'
我已经通过pip安装了这个模块。
我已尝试使用以下命令附加脚本位置的路径:
sys.path.append(r'C:\Users\jgpfi_000\Documents\housescrapeapp\app_index.py')
但同样的错误仍然会发生。