Flask-Script: from flask._compat import text_type ModuleNotFoundError: No module named 'flask._compat' Flask-Script: from flask._compat import text_type ModuleNotFoundError: No module named 'flask._compat' flask flask

Flask-Script: from flask._compat import text_type ModuleNotFoundError: No module named 'flask._compat'


Did you update Flask to version 2.0.0 ?Degrade Flask to version 1.1.2 and it'll work.

EDIT
Instead of using with Flask-Script, you can simply use the below commands :

flask db init to initialize the database
flask db migrate to migrate new changes
flask db upgrade to upgrade and so on.


1 - I did installed modules manualy on PyCharm\settings\projet: myapp\python interpreter by selecting my interpreter and installing libs missed like Flask itself, flask-migrate and flask-script.

2 - On this specific error: from flask._compat import text_type
ModuleNotFoundError: No module named 'flask._compat' -

It happened because the python searched on Flask._compat directory and It isn't there, so I changed like on below : (on flask_script/__init__.py)

Where:

from ._compat import text_type on original flask-script file

to :

from flask_script._compat import text_type

Then It works !!


I removed "from flask_script import Manager"and removed "manager = Manager(app)" from my main app.

And from the requirements.txt file.

Found on github:flask_script is not flask itself, but a (dead - repo archived) flask extension written by someone else.

Now my program runs with Flask 2.0.1