ModuleNotFoundError:没有名为“ flask_session”的模块(即使我已安装flask_session)

时间:2019-07-26 06:59:35

标签: flask flask-session

我已经安装了pip和flask_session,但是当我想运行该应用程序时仍然无法使用

我尝试安装flask_session但已安装(我正在使用pycharm专业版,因此​​我认为它已经包含了所有内容,但似乎不包含!)

from flask_session import Session
from flask import Flask, render_template, request, session


app = Flask(__name__)

app.config["SESSION_PERMANENT"]= False
app.config["SESSION_TYPE"]="filesystem"
Session(app)

notes=[]

@app.route('/', methods=["POST","GET"])
def main():
    if session.get("notes") is None:
        session["notes"]=[]
    if request.method=="POST":
        note = request.form.get("note")
        session["notes"].append(note)
    return render_template("index.html",notes=notes)



FLASK_APP = app.py
FLASK_ENV = development
FLASK_DEBUG = 0
In folder C:/Users/ASUS/jadid
C:\Users\ASUS\jadid\venv\Scripts\python.exe -m flask run
 * Serving Flask app "app.py"
 * Environment: development
 * Debug mode: off
Usage: python -m flask run [OPTIONS]

Error: While importing "app", an ImportError was raised:

Traceback (most recent call last):
  File "C:\Users\ASUS\jadid\venv\lib\site-packages\flask\cli.py", line 240, in locate_app
    __import__(module_name)
  File "C:\Users\ASUS\jadid\app.py", line 1, in <module>
    from flask_session import Session
ModuleNotFoundError: No module named 'flask_session'


Process finished with exit code 2`enter code here`

0 个答案:

没有答案