• Register
0 votes


Tried running a file with the following imports:

from flask_sqlalchemy import sqlalchemy
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker

Received the following error:

ImportError: No module named 'flask_sqlalchemy'

SQLAlchemy is installed. Still, I tried to reinstall into the directory in which it will be used.

13k points

Please log in or register to answer this question.

1 Answer

0 votes


 SQLAlchemy is an expansion for Flask that adds uphold for SQLAlchemy to your application. It intends to improve on utilizing SQLAlchemy with Flask by giving valuable defaults and additional assistants that make it simpler to achieve regular assignments.

It would seem that you may have just introduced the SQLAlchemy bundle and NOT the Flask Extension. Attempt pip introduce Flask-SQLAlchemy

I think you have a befuddle between your pip and python variants. check your pip form pip - adaptation, in the event that it is pip3

you can attempt this,

sudo adept get introduce python3-sqlalchemy

This should work.

~$ python3

>>import sqlalchemy

In the event that you are on macintosh, attempt pip introduce cup sqlalchemy rather than pip3 introduce flagon sqlalchemy.

It works for certain admonitions, yet had the option to succesfully associate with the data set and make the tables. "FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds critical overhead and will be incapacitated naturally later on. Set it to True or False to stifle this notice."

At last, I settled this issue ages after I posted the above inquiry.

The fix was to run all bundle refreshes and introduces through Anaconda and manage my job in Spyder.

The exercise learned was straightforward: Once you begin utilizing Anaconda as your go-to climate for everything Python, all updates - made through conda introduce or pip - will be arranged and set in your framework by Anaconda of course.

Perhaps it is a pip way issue. In the event that utilizing conda virtual env (with boa constrictor or miniconda), check which pip and which python in linux (discover your pip and python way) and ensure they're adjusted. Fix your pip way issue or rather than pip introduce flask_sqlalchemy do a

24.2k points