Question

Despite installing babel I am rather amused yet annoyed that Flask and Babel do not work.

pip install babel
pip install Flask-Babel
Traceback (most recent call last):
  File "run.py", line 8, in <module>
    from app import app
  File "/home/ubuntu/workspace//dashboard/app/__init__.py", line 3, in <module>
    from flaskext.babel import Babel
ImportError: No module named babel
Was it helpful?

Solution 2

Change this

from flaskext.babel import Babel

to

from flask.ext.babel import Babel

Note the . before and after 'ext'. The syntax you are using is the old methodology of importing flask extensions. But for the past few versions, flask made it a standard way of importing extensions. Read the last paragraph here

OTHER TIPS

Try this

from flask_babel import Babel 

I think it follows the convention that when the installation name is separated by a -, then imports can be done when replaced by an underscore

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top