Search code examples
pythonpython-3.xsqlalchemypipapache-superset

ImportError: cannot import name '_ColumnEntity' from 'sqlalchemy.orm.query'


After installing apache-superset using pip in virtual environment, I run:

superset upgrade db   

I run into the following error:

ImportError: cannot import name '_ColumnEntity' from 'sqlalchemy.orm.query' (/Users/ahmedawny/supersetenv/lib/python3.7/site-packages/sqlalchemy/orm/query.py)

Any advice would be appreciated.


Solution

  • The core reason for this is that sqlalchemy 1.4 shipped, so it is now the default that pip installs. There were many interface changes and a new query interface added.

    So upgrading to 1.4 breaks stuff that depends on the sqlalchemy 1.3 API internals. In your requirements.txt file-- pin the project version to the 1.3.x series until the rest of your stuff catches up. For example, as of this date sqlalchemy-utils is still dependent on sqlalchemy 1.3x.

    requirements.txt:

    sqlalchemy < 1.4.0
    

    Then use:

    pip -r requirements.txt
    

    to "downgrade" to the pinned version.