Question

I'm trying to hook flask to mongoengine. All modules seem to have been installed succesfully. Here is my import and ln 4 is where the Error is originating:

import os
from flask import Flask, render_template, send_from_directory
from mongoengine import connect
from flask.ext.mongoengine import MongoEngine

Here is the error I am getting:

File "app.py", line 4, in <module>
from flask.ext.mongoengine import MongoEngine
File "/Users/name/Desktop/venv3/lib/python2.7/site-packages/flask/exthook.py" line 87, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.mongoengine

Any ideas of what I may be doing wrong or how I can procure flask.ext.mongoengine?

Was it helpful?

Solution

You need to install flask-mongoengine before you can use it, e.g.,

pip install flask-mongoengine

This will install a package called flask_mongoengine. Until you do that, Flask will have no knowledge about it. That is what causes your from flask.ext.mongoengine import MongoEngine statement to fail.

from flask.ext import X is a convenience inside Flask that will look for packages named flask_X (falling back to flaskext.X for legacy reasons). If you'd like to learn more about the specifics of the import hook used by Flask, the details are in exthook.py.

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