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

We Are Going To Discuss About Flask-Script: from flask._compat import text_type ModuleNotFoundError: No module named ‘flask._compat’. So lets Start this Python Article.

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

  1. How to solve 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.

  2. 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.

Solution 1

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.

Original Author Ashutosh Krishna Of This Content

Solution 2

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 !!

Original Author Junior Of This Content

Solution 3

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

Original Author Henk Van Hoek Of This Content

Solution 4

Downgrading to flask-script==2.0.5 worked for me, even while using Flask==2.0.2.

Original Author SunnyPro Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment