简体   繁体   中英

Error in Heroku with Flask App and sqlalchemy

I have an app written in Python using Flask that I'm deploying using Heroku. I'm running into an issue after the built, the console gives me numerous lines of error but the main one being, to me:

ImportError: cannot import name 'Binary' from 'sqlalchemy' (/app/.heroku/python/lib/python3.8/site-packages/sqlalchemy/__init__.py)

The related file begins with:

from flask_login import UserMixin
from sqlalchemy import Binary, Column, Integer, String
from app import db, login_manager

My requirement.txt file is a follow:

flask
sqlalchemy
flask_login
flask_migrate
flask_wtf
flask-sqlalchemy
email_validator
python-decouple
gunicorn
fiona
pyproj
rtree
shapely
geopandas
plotly
matplotlib
tqdm

I fail to understand the origin mainly particulalry considering that:

  • the app run fine on my computer (however it runs in a conda env, not pip)
  • the app was fine a few days ago, nothing related to SQL has changed since

Does someone know where it could be coming from?

Thank you!

For posterity, I solved it by being more precise in my requirement files as follow:

flask
sqlalchemy==1.3.23
flask_login
flask_migrate
flask_wtf
flask-sqlalchemy>=2.5
email_validator
python-decouple
gunicorn
fiona
pyproj
rtree
shapely
geopandas
plotly
matplotlib
tqdm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM