U.Reader
U.Reader

Reputation: 21

cannot import name SQLALchemy

I have installed flask-sqlalchemy via pip.But something wrong happened when I run the program,that is, "cannot import name SQLALchemy"At first,I thought the problem was the improper installation.However,I still couldn't solve the problem after several uninstall and installation.Then I change the first line into "from flask_sqlalchemy import sqlalchemy" ,it became "name SQLALchemy is not defined",Still didn't work...What should I do?enter image description hereenter image description here

Upvotes: 2

Views: 5910

Answers (2)

TrakJohnson
TrakJohnson

Reputation: 2097

I believe that imports are case sensitive.

Try from flask_sqlalchemy import SQLAlchemy instead of SQLALchemy

Upvotes: 1

Philippe Ombredanne
Philippe Ombredanne

Reputation: 2025

Try to run your Python interpreter and then use:

>>> from flask import Flask
>>> from flask_sqlalchemy import SQLAlchemy

this should work. Your original code has a typo

Upvotes: 1

Related Questions