ImportError: cannot import name '_literal_as_label_reference' from 'sqlalchemy.sql.elements'

Viewed 590
import pandas as pd
from sqlalchemy import create_engine
import json


read_settings = lambda file: json.loads(open(file, 'r').read())
click_sett = read_settings('click_settings.json')
conn_str = 'clickhouse+http://{}:{}@{}:8123/'.format(click_sett['user'],
                                                    click_sett['password'],
                                                    click_sett['host'])
# I had an exception after that
engine = create_engine(conn_str)

I have updated anaconda : conda update --all After that, I take import error message

Can you help to resolve this problem please? it was normal yesterday.

Traceback: .............

ImportError: cannot import name '_literal_as_label_reference' from 'sqlalchemy.sql.elements' (/Users/user/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/sql/elements.py)

I think that problem in sqlalchemy new version, now is 1.4.27.

1 Answers

For solving this problem you need to use SQLAlchemy < 1.4 version:

pip install SQLAlchemy==1.3.24

Before updating conda save your all packages versions:

pip freeze > last_biuld.txt

If you will get an exception, you can see what was changed in packages.

Related