Encountering errors like modulenotfounderror: no module named ‘flask.ext’ in Python is common. This error occurs when you import a Flask extension that’s been deleted from the most recent Flask release.
In this article, we will show you how to solve the error stating
modulenotfounderror: no module named 'flask.ext'. But before that, let’s first have a brief understanding of Python.
What is Python?
Python is one of the most popular programming languages. It is used for developing a wide range of applications. It is a high-level programming language that is usually used by developers nowadays due to its flexibility.
Returning to our issue, we must take a few actions to fix this error. So, without further ado, let’s move on to our “how to fix this error” tutorial.
How to solve “no module named ‘flask.ext’” in Python
Here’s how to resolve the error message stating
modulenotfounderror: no module named 'flask.ext' in Python.
- Update the Flask installation.
Resolving the error
modulenotfounderror: no module named 'flask.ext'is an easy task. All you have to do is update your Flask installation and revise your code when importing extensions from their packages.
To update your Flask installation, input the command
pip install --upgrade Flask.
pip install --upgrade Flaskwill update your Flask installation to its latest version.
- Revise your code.
After updating your Flask installation, revise or change your code when importing extensions right from their own packages.
Instead of using the code
from flask.ext.bootstrap import Bootstrapto import, revise your code to
from flask_bootstrap import Bootstrap.
Instead of using the flask.ext.sqlalchemy extension, revise your code to
from flask_sqlalchemy import SQLAlchemy.
Tip: After updating your Flask installation and revising your code, test your code by running your Flask application to check if there are any errors.
Commands you might need
This command will display all the packages installed on your system, including their versions.
If you’re using Jupyter Notebook, use the
!pip listcommand instead of
pip list. However, if you’re using Anaconda, use the command
Use this command if you want to check what version of Python you have.
In conclusion, the error modulenotfounderror: no module named ‘flask.ext’ can be easily solved by updating your Flask installation and revising your code when importing extensions from their packages.
By following the guide above, there’s no doubt that you’ll be able to resolve this error quickly.
We hope you’ve learned a lot from this. If you have any questions or suggestions, please leave a comment below, and for more Python tutorials, visit our website.
Thank you for reading!