Home > database >  Flask-SQLAlchemy raises ImportError: cannot import name 'app_ctx' from 'flask.globals
Flask-SQLAlchemy raises ImportError: cannot import name 'app_ctx' from 'flask.globals

Time:10-13

I have a Flask app with the following requirements.txt:

flask==2.1.3
flask-sqlalchemy

I started getting the following error when I run the app:

ImportError: cannot import name 'app_ctx' from 'flask.globals'

Why did this error start happening, and how do I fix it?

CodePudding user response:

Flask-SQLAlchemy 3 requires Flask >= 2.2. Update Flask.

CodePudding user response:

or you can use flask-sqlalchemy==2.5.1 flask-sqlalchemy newest version is 3.0.0, which is pulished on 10/4/2022,if you have to use this version, code change is needed

  • Related