ImportError: No module named sqlalchemy
Did you install flask-sqlalchemy
? It looks like you have SQLAlchemy installed but not the Flask extension. Try pip install Flask-SQLAlchemy
in your project's virtualenv to install it from PyPI.
I just experienced the same problem. Apparently, there is a new distribution method, the extension code is no longer stored under flaskext
.
Source: Flask CHANGELOG This worked for me:
from flask_sqlalchemy import SQLAlchemy
Install Flask-SQLAlchemy with pip in your virtualenv:
pip install flask_sqlalchemy
Then import flask_sqlalchemy
in your code:
from flask_sqlalchemy import SQLAlchemy
Okay,I have re-installed the package via pip even that didn't help. And then I rsync'ed the entire /usr/lib/python-2.7 directory from other working machine with similar configuration to the current machine.It started working. I don't have any idea ,what was wrong with my setup. I see some difference "print sys.path" output earlier and now. but now my issue is resolved by this work around.
EDIT:Found the real solution for my setup. upgrading "sqlalchemy only doesn't solve the issue" I also need to upgrade flask-sqlalchemy
that resolved the issue.
try this:
from flask.ext.sqlalchemy import SQLAlchemy