I want to use flask_sqlalchemy. However, I get a ModuleNotFoundError

  python, sqlalchemy

The following error message is displayed even though it should have been done correctly.

I’ve included my code below, the error code and the
I have attached an image of the pip3 list.

from flask import Flask
    from flask import render_template
    from flask_sqlalchemy import SQLAlchemy
    from datetime import datetime
    import pytz
    
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///blog.db'
    db = SQLAlchemy(app)
    
    
    class User(db.Model):
        id = db.Column(db.Integer, primary_key=True)
        title = db.Column(db.String(50), nullable=False)
        body = db.Column(db.String(3000), nullable=False)
        created_at = db.Column(db.DateTime, nullable=False,
                               default=datetime.now(pytz.timezone('Asia/Tokyo')))
    
    
    @app.route('/')
    def index():
        return render_template('index.html')
    
    
    @app.route('/create')
    def create():
        return render_template('create.html')

Error code.

from flask_sqlalchemy import SQLAlchemy ModuleNotFoundError was
raised, there is no module named ‘flask_sqlalchemy’.

enter image description here

Source: Python Questions

LEAVE A COMMENT