Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1324105: ImportError: cannot import name 'string_types' from 'sqlalchemy.util.compat' due to latest SQLAlchemy version #485

Closed
sshah90 opened this issue Apr 11, 2024 · 7 comments · Fixed by #486
Assignees
Labels
bug Something isn't working status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. status-triage_done Initial triage done, will be further handled by the driver team

Comments

@sshah90
Copy link

sshah90 commented Apr 11, 2024

Please answer these questions before submitting your issue. Thanks!

  1. What version of Python are you using?

    3.10

  2. What operating system and processor architecture are you using?

    macOS-14.4.1-x86_64-i386-64bit

  3. What are the component versions in the environment (pip freeze)?

I created brand new virtual environments and install snowflake-sqlalchemy

asn1crypto==1.5.1
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==3.3.2
cryptography==42.0.5
filelock==3.13.4
greenlet==3.0.3
idna==3.7
packaging==24.0
platformdirs==4.2.0
pycparser==2.22
PyJWT==2.8.0
pyOpenSSL==24.1.0
pytz==2024.1
requests==2.31.0
snowflake-connector-python==3.8.1
snowflake-sqlalchemy==1.5.2
sortedcontainers==2.4.0
**SQLAlchemy==2.0.29**
tomlkit==0.12.4
typing_extensions==4.11.0
urllib3==2.2.1
  1. What did you do?
    I installed newest version of snowflake-sqlalchemy v1.5.2 which brings SQLAlchemy==2.0.29 which causing import errors.

With v1.5.1, it's working fine.

I ran below import command

from snowflake.sqlalchemy import URL

I got below Error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/##/Desktop/python-virtual/poetry-test/lib/python3.10/site-packages/snowflake/sqlalchemy/__init__.py", line 30, in <module>
    from . import base, snowdialect
  File "/Users/##/Desktop/python-virtual/poetry-test/lib/python3.10/site-packages/snowflake/sqlalchemy/base.py", line 20, in <module>
    from sqlalchemy.util.compat import string_types
ImportError: cannot import name 'string_types' from 'sqlalchemy.util.compat' (/Users/###/Desktop/python-virtual/poetry-test/lib/python3.10/site-packages/sqlalchemy/util/compat.py)

Do we need to lock dependency at pyproject.toml ?

  1. What did you expect to see?

It should be able to import URL without any failures.

@sshah90 sshah90 added bug Something isn't working needs triage labels Apr 11, 2024
@github-actions github-actions bot changed the title ImportError: cannot import name 'string_types' from 'sqlalchemy.util.compat' due to latest SQLAlchemy version SNOW-1324105: ImportError: cannot import name 'string_types' from 'sqlalchemy.util.compat' due to latest SQLAlchemy version Apr 11, 2024
@jessfreedom
Copy link

running into same issue with Python 3.11.6, macOS-14.4.1 M2 Pro
asn1crypto==1.5.1 Cerberus==1.3.5 certifi==2024.2.2 cffi==1.16.0 charset-normalizer==3.3.2 click==8.1.7 click-default-group==1.2.4 colorama==0.4.6 coloredlogs==15.0.1 cryptography==42.0.5 filelock==3.13.4 humanfriendly==10.0 idna==3.7 importlib_metadata==7.1.0 jaraco.classes==3.4.0 keyring==24.3.1 more-itertools==10.2.0 packaging==24.0 permifrost==0.15.4 platformdirs==4.2.0 pycparser==2.22 PyJWT==2.8.0 pyOpenSSL==24.1.0 pytz==2024.1 PyYAML==6.0.1 requests==2.31.0 snowflake-connector-python==3.8.1 snowflake-sqlalchemy==1.5.2 sortedcontainers==2.4.0 SQLAlchemy==2.0.29 tomlkit==0.12.4 typing_extensions==4.11.0 urllib3==2.2.1 zipp==3.18.1

@cboulanger23
Copy link

cboulanger23 commented Apr 12, 2024

Same issue trying to use Django 4.2 + django-snowflake 4.2 which has a dependency on snowflake-sqlalchemy (~=1.5.x). Reverting snowflake-sqlalchemy version 1.5.2 to 1.5.1 fixed the issue.
Python 3.8.13, x86_64, ubuntu 20.04

@jessfreedom
Copy link

jessfreedom commented Apr 12, 2024

Yeah, looks like there's something wrong with the latest version. Might be something to do with updating to using the latest version of sqlalchemy 2.0. Pinning to 1.5.1 worked - it's still using sqlalchemy 1.4.

@aclemente-tkww
Copy link

From a quick look, it seems like between versions, this package changed from specifying the dependencies with setup.cfg

sqlalchemy<2.0.0,>=1.4.0

To using pyproject.toml + hatch

dependencies = ["snowflake-connector-python", "SQLAlchemy"]

I am not familiar with hatch, but looks like there's a version requirement missing in the specifier.
Either that, or this change was on purpose and we missed some announcement or doc.
In any case, this does not seem like a change to do in a patch version.

@sfc-gh-dszmolka
Copy link
Contributor

hi folks, thanks for reporting - yes definitely this is unexpected and not a planned change to go to sqlalchemy 2 in a patch version but rather a bug. We'll take a look.

@sfc-gh-dszmolka sfc-gh-dszmolka added status-triage_done Initial triage done, will be further handled by the driver team status-in_progress Issue is worked on by the driver team and removed needs triage labels Apr 14, 2024
@sfc-gh-dszmolka
Copy link
Contributor

fix is #486 which is now merged. I'm reopening this issue to be able to properly track, because we need to release the next version which carries the fix

expected by latest April release cycle (end of month)

@sfc-gh-dszmolka sfc-gh-dszmolka added status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. and removed status-in_progress Issue is worked on by the driver team labels Apr 15, 2024
@sfc-gh-dszmolka
Copy link
Contributor

fix released with v1.5.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status-fixed_awaiting_release The issue has been fixed, its PR merged, and now awaiting the next release cycle of the connector. status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
5 participants