I have Flask, Babel and Flask-Babel installed in the global packages.
When running python and I type this, no error
>>> from flaskext.babel import Babel
>>>
With a virtual environment, starting python and typing the same command I see
>>> from flaskext.babel import Babel
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named flaskext.babel
>>>
The problem is that I’m using Ninja-IDE and I’m apparently forced to use a virtualenv. I don’t mind as long as it doesn’t break Flask packing system.
Yeah! I solved the problem!
Creating an empty _init_py in the global Lib/site-packages/flaskext next to the babel.py file solves the problem.
Importing Babel from the local environment now works as expected and as it worked in the global environment.
We can use the two forms from flaskext.babel import Babel and from babel.ext.babel import Babel. However the forms *from flask_babel import Babel* or *import flask_babel* don’t work.
Note that I’m running on Windows 7 64bit with Python 2.7 in C:\Python27. The absence of init.py file may not be a problem on unix computers.