문제

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
도움이 되었습니까?

해결책 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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top