在anaconda提示符下运行Python脚本时发生ModuleNotFoundError
我试图在Anaconda提示符下运行以下Flask应用程序在anaconda提示符下运行Python脚本时发生ModuleNotFoundError,python,flask,pip,anaconda,Python,Flask,Pip,Anaconda,我试图在Anaconda提示符下运行以下Flask应用程序 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_f
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 <module>
from flask import Flask, flash, redirect, url_for, render_template, request, session, abort
ModuleNotFoundError: No module named 'flask'
但是同样的错误仍然存在。通常安装了两个版本的Python,2.x和3.x版本 如果使用
pip
,则2.x版本的站点库将被更新,为了在3.x版本中安装所需的软件包,您可以使用以下方法:
python -m pip install flask
通过卸载Python 3.7并在anaconda提示符下运行
Python app_index.py
,conda list
的输出是什么?flask在列表中:flask 0.12.2 py36_0 flask cors 3.0.2 py36_0
@darthbith如果运行该怎么办python app_index.py
而不是py app_index.py
?是的,在卸载python 3.7后修复了它
python -m pip install flask