How To Fix “ImportError: cannot import name ‘_ColumnEntity’ from ‘sqlalchemy.orm.query’”?
Are you having problems with the issue “ImportError: cannot import name ‘_ColumnEntity’ from ‘sqlalchemy.orm.query’“? How to fix it? In today’s article, I will provide solutions for you to solve the issues. Please follow the below steps to get the problem resolved now
How did “ImportError: cannot import name ‘_ColumnEntity’ from ‘sqlalchemy.orm.query’” occur?
ImportError: cannot import name ‘_ColumnEntity’ from ‘sqlalchemy.orm.query’
When you work with Python, you may get the issue ImportError: cannot import name ‘_ColumnEntity’ from ‘sqlalchemy.orm.query’. Don’t worry, we are here to provide you solutions in order to resolve your problem.
How to fix “ImportError: cannot import name ‘_ColumnEntity’ from ‘sqlalchemy.orm.query’”?
Question: How to solve ImportError: cannot import name ‘_ColumnEntity’ from ‘sqlalchemy.orm.query’ ?Answer to the Problem is sqlalchemy 1.1.4 shipped. It is now the default pip install. Many interface changes were made and a new query interface was added. Upgrades to 1.4 will cause problems for stuff that relies on sqlalchemy API internals. The solution is to downgrade sqlalchemy.
Solution 1
The problem is sqlalchemy1.4 shipped. It is now the default pip install. Many interface changes were made and a new query interface was added.
Upgrades to 1.4 will cause problems for stuff that is dependent on the sqlalchemy API internals. The solution is to downgrade sqlalchemy.
To downgrade the version, follow the command line below.
requirements.txt:
sqlalchemy < 1.4.0
Then use:
pip -r requirements.txt
To “downgrade” the pinned version.
This solution worked for me.
Solution 2
We just wanted to mention that Flask AppBuilder has a new release that pins SQLAlchemy bellow 1.4.
Final words
The above are useful solutions that can help you fix “ImportError: cannot import name ‘_ColumnEntity’ from ‘sqlalchemy.orm.query’” problem, if you can’t solve it well. Please leave a message.