Issue
I've been using this tutorial to setup flask on ubuntu server. It worked fine for one project, now I try to setup it on the other one. This time the app works fine without SQLAlchemy, but once I use it, it gives 'Internal server error'.
- checked the installation of flask_sqlalchemy - looks fine
- made sure I don't have a file named 'sqlalchemy'
- I can launch the app with sqlalchemy but without virtualenv, it works fine!
- I double-checked that flask_sqlalchemy has the same configuration in virtualenv library, as in the python library
error that I receive:
Traceback (most recent call last):
File "myproject2.py", line 4, in <module>
from flask_sqlalchemy import SQLAlchemy
File "/root/myproject2/myprojectenv2/lib/python3.8/site-packages/flask_sqlalch emy/__init__.py", line 16, in <module>
from sqlalchemy import event, inspect, orm
ImportError: cannot import name 'inspect' from 'sqlalchemy' (/root/myproject2/my projectenv2/lib/python3.8/site-packages/sqlalchemy/__init__.py)
Thank you for any suggestions!
Solution
It seems your installation is broken in the virtualenv. Try reinstalling by running this from within the virtualenv:
pip install --upgrade --force-reinstall flask-sqlalchemy sqlalchemy
Answered By - 2e0byo Answer Checked By - Mildred Charles (WPSolving Admin)