Я просто прохожу курс Python по Удеми. Это внутренняя часть программы, работающая в виртуальной среде в коде Visual Studio.
from flask import Flask, render_template, request
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI']='postgresql://postgres:********@localhost/height-email_collector'
db = SQLAlchemy(app)
class Data(db.Model):
__tablename__ ="data"
id =db.Column(db.Integer, primary_key=True)
email_ =db.Column(db.String(120), unique=True)
height_ =db.Column(db.Integer)
def __init__(self, email_,height_):
self.email_ = email_
self.height_ = height_
@app.route("/")
def Index():
return render_template('index.html')
@app.route("/success", methods =['POST'])
def success():
if request.method=='POST':
email = request.form["email_name"]
height = request.form["height_name"]
print(email, height)
data = Data(email,height)
db.session.add(data)
db.session.commit()
return render_template('success.html')
if __name__ == '__main__':
app.debug = True
app.run()
Когда я выполняю код, я получаю следующее:
(virtual) C:\Users\lenovo\Desktop\My_Python\Py_html> py -3 App10.py
Traceback (most recent call last):
File "App10.py", line 1, in <module>
from flask import Flask, render_template, request
ModuleNotFoundError: No module named 'flask'
Даже Я переустановил пакеты, но не могу решить проблему