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-911255: Getting import error: cannot import name 'string_types' from 'sqlalchemy.util.compat' #445

Closed
zoharsan opened this issue Sep 8, 2023 · 5 comments
Assignees
Labels
bug Something isn't working duplicate This issue or pull request already exists status-triage_done Initial triage done, will be further handled by the driver team

Comments

@zoharsan
Copy link

zoharsan commented Sep 8, 2023

Please answer these questions before submitting your issue. Thanks!

  1. What version of Python are you using?

    Python 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0]

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

    Linux-5.4.181-99.354.amzn2.x86_64-x86_64-with-glibc2.35

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

absl-py==1.4.0
accelerate==0.22.0
aiohttp @ file:///rapids/aiohttp-3.8.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
aiosignal @ file:///rapids/aiosignal-1.3.1-py3-none-any.whl
anyio==4.0.0
apex==0.1
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
asn1crypto==1.5.1
asttokens==2.2.1
astunparse==1.6.3
async-timeout @ file:///rapids/async_timeout-4.0.2-py3-none-any.whl
attrs==23.1.0
audioread==3.0.0
backcall==0.2.0
backoff==2.2.1
bcrypt==4.0.1
beautifulsoup4==4.12.2
bitsandbytes==0.41.1
bleach==6.0.0
blis==0.7.9
Brotli==1.0.9
cachetools==5.3.1
catalogue==2.0.8
certifi==2023.5.7
cffi==1.15.1
charset-normalizer==2.1.1
chroma-hnswlib==0.7.2
chromadb==0.4.9
click==8.1.3
cloudpickle==2.0.0
cmake==3.24.1.1
coloredlogs==15.0.1
comm==0.1.3
confection==0.0.4
contourpy @ file:///rapids/contourpy-1.0.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
cryptography==36.0.2
cubinlinker @ file:///rapids/cubinlinker-0.3.0%2B2.g87b01ae-cp310-cp310-linux_x86_64.whl
cuda-python @ file:///rapids/cuda_python-12.1.0rc5%2B1.g38940ef-cp310-cp310-linux_x86_64.whl
cudf @ file:///rapids/cudf-23.4.0-cp310-cp310-linux_x86_64.whl
cugraph @ file:///rapids/cugraph-23.4.0-cp310-cp310-linux_x86_64.whl
cugraph-dgl @ file:///rapids/cugraph_dgl-23.4.0-py3-none-any.whl
cugraph-service-client @ file:///rapids/cugraph_service_client-23.4.0-py3-none-any.whl
cugraph-service-server @ file:///rapids/cugraph_service_server-23.4.0-py3-none-any.whl
cuml @ file:///rapids/cuml-23.4.0-cp310-cp310-linux_x86_64.whl
cupy-cuda12x @ file:///rapids/cupy_cuda12x-12.0.0b3-cp310-cp310-linux_x86_64.whl
cycler==0.11.0
cymem==2.0.7
Cython==0.29.35
dask @ file:///rapids/dask-2023.3.2-py3-none-any.whl
dask-cuda @ file:///rapids/dask_cuda-23.4.0-py3-none-any.whl
dask-cudf @ file:///rapids/dask_cudf-23.4.0-py3-none-any.whl
dataclasses-json==0.5.14
datasets==2.14.4
debugpy==1.6.7
decorator==5.1.1
defusedxml==0.7.1
dill==0.3.7
distributed @ file:///rapids/distributed-2023.3.2.1-py3-none-any.whl
einops==0.6.1
exceptiongroup==1.1.1
execnet==1.9.0
executing==1.2.0
expecttest==0.1.3
faiss-gpu==1.7.2
fastapi==0.99.1
fastjsonschema==2.17.1
fastrlock @ file:///rapids/fastrlock-0.8.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_24_x86_64.whl
filelock==3.12.2
fire==0.5.0
flash-attn==1.0.7
flatbuffers==23.5.26
fonttools @ file:///rapids/fonttools-4.39.4-py3-none-any.whl
frozenlist @ file:///rapids/frozenlist-1.3.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
fschat==0.2.26
fsspec @ file:///rapids/fsspec-2023.5.0-py3-none-any.whl
gast==0.4.0
google-auth==2.20.0
google-auth-oauthlib==0.4.6
graphsurgeon @ file:///workspace/TensorRT-8.6.1.6/graphsurgeon/graphsurgeon-0.4.6-py2.py3-none-any.whl
greenlet==2.0.2
grpcio==1.56.0
h11==0.14.0
httpcore==0.17.3
httptools==0.6.0
httpx==0.24.1
huggingface-hub==0.16.4
humanfriendly==10.0
hypothesis==5.35.1
idna==3.4
importlib-metadata @ file:///rapids/importlib_metadata-6.6.0-py3-none-any.whl
importlib-resources==6.0.1
inflate64==0.3.1
iniconfig==2.0.0
intel-openmp==2021.4.0
ipykernel==6.23.3
ipython==8.14.0
ipython-genutils==0.2.0
ipywidgets==8.1.0
jedi==0.18.2
Jinja2==3.1.2
joblib==1.2.0
json5==0.9.14
jsonschema==4.17.3
jupyter==1.0.0
jupyter-console==6.6.3
jupyter-tensorboard @ git+https://github.com/cliffwoolley/jupyter_tensorboard.git@ffa7e26138b82549453306e06b535a9ac36db17a
jupyter_client==8.3.0
jupyter_core==5.3.1
jupyterlab==2.3.2
jupyterlab-pygments==0.2.2
jupyterlab-server==1.2.0
jupyterlab-widgets==3.0.8
jupytext==1.14.6
kiwisolver==1.4.4
langchain==0.0.279
langcodes==3.3.0
langsmith==0.0.32
librosa==0.9.2
llvmlite @ file:///rapids/llvmlite-0.39.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
locket @ file:///rapids/locket-1.0.0-py2.py3-none-any.whl
Markdown==3.4.3
markdown-it-py==2.2.0
markdown2==2.4.10
MarkupSafe==2.1.3
marshmallow==3.20.1
matplotlib==3.7.1
matplotlib-inline==0.1.6
mdit-py-plugins==0.4.0
mdurl==0.1.2
mistune==3.0.1
mkl==2021.1.1
mkl-devel==2021.1.1
mkl-include==2021.1.1
mock==5.0.2
monotonic==1.6
mpmath==1.3.0
msgpack @ file:///rapids/msgpack-1.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
multidict @ file:///rapids/multidict-6.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
multiprocess==0.70.15
multivolumefile==0.2.3
murmurhash==1.0.9
mypy-extensions==1.0.0
nbclient==0.8.0
nbconvert==7.6.0
nbformat==5.9.0
nest-asyncio==1.5.6
networkx==2.6.3
nh3==0.2.14
ninja==1.11.1
nltk==3.8.1
notebook==6.4.10
numba @ file:///rapids/numba-0.56.4%2B1.g5f1bc7084-cp310-cp310-linux_x86_64.whl
numexpr==2.8.5
numpy==1.25.2
nvidia-dali-cuda120==1.26.0
nvidia-pyindex==1.0.9
nvtx @ file:///rapids/nvtx-0.2.5-cp310-cp310-linux_x86_64.whl
oauthlib==3.2.2
onnx @ file:///opt/pytorch/pytorch/third_party/onnx
onnxruntime==1.15.1
openai==0.27.8
opencv @ file:///opencv-4.6.0/modules/python/package
oscrypto==1.3.0
overrides==7.4.0
packaging==23.1
pandas @ file:///rapids/pandas-1.5.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pandocfilters==1.5.0
parso==0.8.3
partd @ file:///rapids/partd-1.4.0-py3-none-any.whl
pathy==0.10.2
peft==0.5.0
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.5.0
platformdirs==3.8.0
pluggy==1.2.0
ply @ file:///rapids/ply-3.11-py2.py3-none-any.whl
polygraphy==0.47.1
pooch==1.7.0
posthog==3.0.2
preshed==3.0.8
prettytable==3.8.0
prometheus-client==0.17.0
prompt-toolkit==3.0.38
protobuf==3.20.0
psutil @ file:///rapids/psutil-5.9.4-cp310-abi3-linux_x86_64.whl
ptxcompiler @ file:///rapids/ptxcompiler-0.8.1%2B1.gbe9fca5-cp310-cp310-linux_x86_64.whl
ptyprocess==0.7.0
pulsar-client==3.3.0
pure-eval==0.2.2
py7zr==0.20.6
pyarrow==8.0.0
pyasn1==0.5.0
pyasn1-modules==0.3.0
pybcj==1.0.1
pybind11==2.10.4
pycocotools @ git+https://github.com/nvidia/cocoapi.git@fa44301f7a8b3f95a9f2751d19bfd735b0f6c65d#subdirectory=PythonAPI
pycparser==2.21
pycryptodomex==3.18.0
pydantic==1.10.9
Pygments==2.15.1
PyJWT==2.8.0
pylibcugraph @ file:///rapids/pylibcugraph-23.4.0-cp310-cp310-linux_x86_64.whl
pylibcugraphops @ file:///rapids/pylibcugraphops-23.4.0-cp310-cp310-linux_x86_64.whl
pylibraft @ file:///rapids/pylibraft-23.4.0-cp310-cp310-linux_x86_64.whl
pynvml @ file:///rapids/pynvml-11.4.1-py3-none-any.whl
pyOpenSSL==22.0.0
pyparsing @ file:///rapids/pyparsing-3.0.9-py3-none-any.whl
PyPika==0.48.9
pyppmd==1.0.0
pyrsistent==0.19.3
pytest==7.4.0
pytest-rerunfailures==11.1.2
pytest-shard==0.1.2
pytest-xdist==3.3.1
python-dateutil==2.8.2
python-dotenv==1.0.0
python-hostlist==1.23.0
pytorch-quantization==2.1.2
pytz @ file:///rapids/pytz-2023.3-py2.py3-none-any.whl
PyYAML==6.0
pyzmq==25.1.0
pyzstd==0.15.9
qtconsole==5.4.4
QtPy==2.4.0
raft-dask @ file:///rapids/raft_dask-23.4.0-cp310-cp310-linux_x86_64.whl
regex==2023.6.3
requests==2.31.0
requests-oauthlib==1.3.1
resampy==0.4.2
rich==13.5.2
rmm @ file:///rapids/rmm-23.4.0-cp310-cp310-linux_x86_64.whl
rsa==4.9
safetensors==0.3.3
scikit-learn @ file:///rapids/scikit_learn-1.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
scipy @ file:///rapids/scipy-1.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
seaborn @ file:///rapids/seaborn-0.12.2-py3-none-any.whl
Send2Trash==1.8.2
sentence-transformers==2.2.2
sentencepiece==0.1.99
shortuuid==1.0.11
six==1.16.0
smart-open==6.3.0
sniffio==1.3.0
snowflake-connector-python==2.7.12
snowflake-snowpark-python==1.5.1
snowflake-sqlalchemy==1.5.0
sortedcontainers==2.4.0
soundfile==0.12.1
soupsieve==2.4.1
spacy==3.5.3
spacy-legacy==3.0.12
spacy-loggers==1.0.4
sphinx-glpi-theme==0.3
SQLAlchemy==1.4.49
srsly==2.4.6
stack-data==0.6.2
starlette==0.27.0
svgwrite==1.4.3
sympy==1.12
tabulate==0.9.0
tbb==2021.9.0
tblib @ file:///rapids/tblib-1.7.0-py2.py3-none-any.whl
tenacity==8.2.3
tensorboard==2.9.0
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tensorrt @ file:///workspace/TensorRT-8.6.1.6/python/tensorrt-8.6.1-cp310-none-linux_x86_64.whl
termcolor==2.3.0
terminado==0.17.1
texttable==1.6.7
thinc==8.1.10
threadpoolctl==3.1.0
thriftpy2 @ file:///rapids/thriftpy2-0.4.16-cp310-cp310-linux_x86_64.whl
tiktoken==0.4.0
tinycss2==1.2.1
tokenizers==0.13.3
toml==0.10.2
tomli==2.0.1
toolz @ file:///rapids/toolz-0.12.0-py3-none-any.whl
torch==2.1.0a0+4136153
torch-tb-profiler==0.4.1
torch-tensorrt @ file:///opt/pytorch/torch_tensorrt/py/dist/torch_tensorrt-1.5.0.dev0-cp310-cp310-linux_x86_64.whl
torchdata @ file:///opt/pytorch/data
torchtext @ file:///opt/pytorch/text
torchvision @ file:///opt/pytorch/vision
tornado==6.3.2
tqdm==4.65.0
traitlets==5.9.0
transformer-engine @ git+https://github.com/NVIDIA/TransformerEngine.git@06cacd205e317d9ce804a87b686ada89e967912d
transformers==4.32.1
treelite @ file:///rapids/treelite-3.2.0-cp310-cp310-linux_x86_64.whl
treelite-runtime @ file:///rapids/treelite_runtime-3.2.0-cp310-cp310-linux_x86_64.whl
triton @ file:///tmp/dist/triton-2.1.0-cp310-cp310-linux_x86_64.whl
typer==0.7.0
types-dataclasses==0.6.6
typing-inspect==0.9.0
typing_extensions==4.6.3
ucx-py @ file:///rapids/ucx_py-0.31.0-cp310-cp310-linux_x86_64.whl
uff @ file:///workspace/TensorRT-8.6.1.6/uff/uff-0.6.9-py2.py3-none-any.whl
urllib3==1.26.16
uvicorn==0.23.2
uvloop==0.17.0
wasabi==1.1.2
watchfiles==0.20.0
wavedrom==2.0.3.post3
wcwidth==0.2.6
webencodings==0.5.1
websockets==11.0.3
Werkzeug==2.3.6
widgetsnbextension==4.0.8
xdoctest==1.0.2
xgboost @ file:///rapids/xgboost-1.7.5-cp310-cp310-linux_x86_64.whl
xxhash==3.3.0
yarl @ file:///rapids/yarl-1.9.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
zict @ file:///rapids/zict-3.0.0-py2.py3-none-any.whl
zipp @ file:///rapids/zipp-3.15.0-py3-none-any.whl

  1. What did you do?

Just trying to run the validate.py program:

from snowflake.snowpark import Session

username = connection_parameters["user"]
password = connection_parameters["password"]
snowflake_account = connection_parameters["account"]
accountname = connection_parameters["account"]
database = connection_parameters["database"]
schema = connection_parameters["schema"]
warehouse = connection_parameters["warehouse"]
role = connection_parameters["role"]

from sqlalchemy import create_engine

engine = create_engine(
'snowflake://{user}:{password}@xxxxx'.format(
user = username,
password = password,
account_identifier = "XXXXX"
)
)
try:
connection = engine.connect()
results = connection.execute('select current_version()').fetchone()
print(results[0])
finally:
connection.close()
engine.dispose()

  1. What did you expect to see?

    I would expect to see the current version. Instead I'm getting this error:

Unexpected exception formatting exception. Falling back to standard exception

Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/IPython/core/interactiveshell.py", line 3508, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "/tmp/ipykernel_1041/3455796532.py", line 27, in
engine = create_engine(
File "", line 2, in create_engine
File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/util/deprecations.py", line 281, in warned
"add warn_on_attribute_access=True. Otherwise please add "
File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/engine/create.py", line 552, in create_engine
File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/engine/url.py", line 754, in _get_entrypoint
(?P[^/:\?]+)
File "/usr/local/lib/python3.10/dist-packages/sqlalchemy/util/langhelpers.py", line 355, in load
File "/usr/lib/python3.10/importlib/metadata/init.py", line 171, in load
module = import_module(match.group('module'))
File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1050, in _gcd_import
File "", line 1027, in _find_and_load
File "", line 1006, in _find_and_load_unlocked
File "", line 688, in _load_unlocked
File "", line 883, in exec_module
File "", line 241, in _call_with_frames_removed
File "/usr/local/lib/python3.10/dist-packages/snowflake/sqlalchemy/init.py", line 30, in
from . import base, snowdialect
File "/usr/local/lib/python3.10/dist-packages/snowflake/sqlalchemy/base.py", line 13, in
from sqlalchemy.util.compat import string_types
ImportError: cannot import name 'string_types' from 'sqlalchemy.util.compat' (/usr/local/lib/python3.10/dist-packages/sqlalchemy/util/compat.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/IPython/core/interactiveshell.py", line 2105, in showtraceback
stb = self.InteractiveTB.structured_traceback(
File "/usr/local/lib/python3.10/dist-packages/IPython/core/ultratb.py", line 1428, in structured_traceback
return FormattedTB.structured_traceback(
File "/usr/local/lib/python3.10/dist-packages/IPython/core/ultratb.py", line 1319, in structured_traceback
return VerboseTB.structured_traceback(
File "/usr/local/lib/python3.10/dist-packages/IPython/core/ultratb.py", line 1172, in structured_traceback
formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
File "/usr/local/lib/python3.10/dist-packages/IPython/core/ultratb.py", line 1087, in format_exception_as_a_whole
frames.append(self.format_record(record))
File "/usr/local/lib/python3.10/dist-packages/IPython/core/ultratb.py", line 969, in format_record
frame_info.lines, Colors, self.has_colors, lvals
File "/usr/local/lib/python3.10/dist-packages/IPython/core/ultratb.py", line 792, in lines
return self._sd.lines
File "/usr/local/lib/python3.10/dist-packages/stack_data/utils.py", line 144, in cached_property_wrapper
value = obj.dict[self.func.name] = self.func(obj)
File "/usr/local/lib/python3.10/dist-packages/stack_data/core.py", line 734, in lines
pieces = self.included_pieces
File "/usr/local/lib/python3.10/dist-packages/stack_data/utils.py", line 144, in cached_property_wrapper
value = obj.dict[self.func.name] = self.func(obj)
File "/usr/local/lib/python3.10/dist-packages/stack_data/core.py", line 681, in included_pieces
pos = scope_pieces.index(self.executing_piece)
File "/usr/local/lib/python3.10/dist-packages/stack_data/utils.py", line 144, in cached_property_wrapper
value = obj.dict[self.func.name] = self.func(obj)
File "/usr/local/lib/python3.10/dist-packages/stack_data/core.py", line 660, in executing_piece
return only(
File "/usr/local/lib/python3.10/dist-packages/executing/executing.py", line 190, in only
raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0

  1. Can you set logging to DEBUG and collect the logs?

N/A

@zoharsan zoharsan added bug Something isn't working needs triage labels Sep 8, 2023
@github-actions github-actions bot changed the title Getting import error: cannot import name 'string_types' from 'sqlalchemy.util.compat' SNOW-911255: Getting import error: cannot import name 'string_types' from 'sqlalchemy.util.compat' Sep 8, 2023
@MadReasonable
Copy link

MadReasonable commented Sep 13, 2023

This is happening to me as well. It looks like string_types was removed from sqlalchemy.util.compat at some point and is no longer in 2.0.20.

Edit: It appears to be gone by 2.0.0. In 1.4.29, string_types is defined on line 150 or 260, depending on your python version

@galvinma
Copy link

Also seeing this issue. Not sure how my environment changed.

ImportError: cannot import name 'string_types' from 'sqlalchemy.util.compat' (/opt/conda/lib/python3.11/site-packages/sqlalchemy/util/compat.py)

Versions:

snowflake-connector-python               3.2.0
snowflake-sqlalchemy                     1.5.0

@mulenitin
Copy link

I am getting the same issue with SQLAlchemy v2.0.21.

@mulenitin
Copy link

Please refer to my issue - #452. I believe your issue also has the same root cause as mine - SQLAlchemy 2.0 is not supported by snowflake-sqlalchemy.

@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Mar 20, 2024
@sfc-gh-dszmolka sfc-gh-dszmolka added duplicate This issue or pull request already exists status-triage_done Initial triage done, will be further handled by the driver team and removed needs triage labels Mar 20, 2024
@sfc-gh-dszmolka
Copy link
Contributor

looks like both #467 and #445 are duplicates of
#452 and caused by the library not yet supporting SQLAlchemy 2.0

implementation efforts on #380 - thank you for bearing with us !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

5 participants