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-1004188: Python cannot import name 'Mapping' from 'collections' #1848

Open
IRISDavidD opened this issue Jan 10, 2024 · 16 comments
Open
Assignees

Comments

@IRISDavidD
Copy link

Python version

3.12

Operating system and processor architecture

Linux-6.5.11-linuxkit-x86_64-with-glibc2.34

Installed packages

awslambdaric==2.0.8
boto3==1.28.72
botocore==1.31.72
jmespath==1.0.1
python-dateutil==2.8.2
s3transfer==0.7.0
simplejson==3.17.2
six==1.16.0
urllib3==1.26.17
sh-5.2# 
sh-5.2# python -m pip3 freeze
/var/lang/bin/python: No module named pip3
sh-5.2# pip freeze --path .
anyio==4.2.0
asn1crypto==0.24.0
azure-common==1.1.28
azure-core==1.29.6
azure-storage-blob==12.19.0
boto3==1.9.253
botocore==1.12.253
certifi==2023.11.17
cffi==1.16.0
charset-normalizer==3.3.2
cryptography==41.0.7
docutils==0.15.2
future==0.18.3
idna==3.6
ijson==3.2.3
isodate==0.6.1
Jinja2==3.1.2
jmespath==0.10.0
MarkupSafe==2.1.3
pycparser==2.21
pycryptodomex==3.20.0
PyJWT==2.8.0
pyOpenSSL==23.3.0
python-dateutil==2.8.2
pytz==2023.3.post1
requests==2.31.0
s3transfer==0.2.1
six==1.16.0
sniffio==1.3.0
snowflake-connector-python==1.9.1
typing_extensions==4.9.0
urllib3==1.25.11

What did you do?

Using a docker container to create a lambda layer for a function. Our current function is in 3.8 and going to be deprecated soon. Would be nice to be able to update it to the latest python version. We can move to 3.9 but would like to use some features in 3.11/3.12

What did you expect to see?

Layer usage but instead get the following error
cannot import name 'Mapping' from 'collections'

Can you set logging to DEBUG and collect the logs?

import logging
import os

for logger_name in ('snowflake.connector',):
    logger = logging.getLogger(logger_name)
    logger.setLevel(logging.DEBUG)
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    ch.setFormatter(logging.Formatter('%(asctime)s - %(threadName)s %(filename)s:%(lineno)d - %(funcName)s() - %(levelname)s - %(message)s'))
    logger.addHandler(ch)
@github-actions github-actions bot changed the title Python cannot import name 'Mapping' from 'collections' SNOW-1004188: Python cannot import name 'Mapping' from 'collections' Jan 10, 2024
@sfc-gh-yixie
Copy link
Collaborator

@IRISDavidD snowpark supports 3.11. Could you try it?

@IRISDavidD
Copy link
Author

I tried 3.11 and get the following issue running:

pip3 install --target=. --platform manylinux2010_x86_64 --only-binary=:all: -r requirements.txt
also tried standard pip3 install

ERROR: Cannot install -r requirements.txt (line 1) because these package versions have conflicting dependencies.

The conflict is caused by:
snowflake-connector-python 1.9.1 depends on future
snowflake-connector-python 1.8.7 depends on future
snowflake-connector-python 1.8.6 depends on future
snowflake-connector-python 1.8.5 depends on future
snowflake-connector-python 1.8.4 depends on future
snowflake-connector-python 1.8.3 depends on future
snowflake-connector-python 1.8.2 depends on future
snowflake-connector-python 1.8.1 depends on future
snowflake-connector-python 1.8.0 depends on future
snowflake-connector-python 1.7.11 depends on future
snowflake-connector-python 1.7.10 depends on future
snowflake-connector-python 1.7.9 depends on future
snowflake-connector-python 1.7.8 depends on future
snowflake-connector-python 1.7.7 depends on future
snowflake-connector-python 1.7.6 depends on future
snowflake-connector-python 1.7.5 depends on future
snowflake-connector-python 1.7.4 depends on future
snowflake-connector-python 1.7.3 depends on future
snowflake-connector-python 1.7.2 depends on future
snowflake-connector-python 1.7.1 depends on future
snowflake-connector-python 1.7.0 depends on future
snowflake-connector-python 1.6.12 depends on future
snowflake-connector-python 1.6.11 depends on future
snowflake-connector-python 1.6.10 depends on future
snowflake-connector-python 1.6.9 depends on future
snowflake-connector-python 1.6.8 depends on future
snowflake-connector-python 1.6.7 depends on future
snowflake-connector-python 1.6.6 depends on future
snowflake-connector-python 1.6.5 depends on future
snowflake-connector-python 1.6.4 depends on future
snowflake-connector-python 1.6.3 depends on future
snowflake-connector-python 1.6.2 depends on future
snowflake-connector-python 1.6.1 depends on future
snowflake-connector-python 1.6.0 depends on future
snowflake-connector-python 1.5.8 depends on future
snowflake-connector-python 1.5.7 depends on future
snowflake-connector-python 1.5.6 depends on cffi>=1.9
snowflake-connector-python 1.5.5 depends on cffi>=1.9
snowflake-connector-python 1.5.4 depends on cffi>=1.9
snowflake-connector-python 1.5.3 depends on cffi>=1.9
snowflake-connector-python 1.5.2 depends on cffi>=1.9
snowflake-connector-python 1.5.1 depends on cffi>=1.9
snowflake-connector-python 1.5.0 depends on cffi>=1.9
snowflake-connector-python 1.4.17 depends on cffi>=1.9
snowflake-connector-python 1.4.16 depends on cffi>=1.9
snowflake-connector-python 1.4.15 depends on cffi>=1.9
snowflake-connector-python 1.4.14 depends on cffi>=1.9
snowflake-connector-python 1.4.13 depends on cffi>=1.9
snowflake-connector-python 1.4.12 depends on cffi>=1.9
snowflake-connector-python 1.4.11 depends on cffi>=1.9
snowflake-connector-python 1.4.10 depends on cffi>=1.9
snowflake-connector-python 1.4.9 depends on cffi>=1.9
snowflake-connector-python 1.4.8 depends on cffi>=1.9
snowflake-connector-python 1.4.7 depends on cffi>=1.9
snowflake-connector-python 1.4.6 depends on cffi>=1.9
snowflake-connector-python 1.4.5 depends on cffi>=1.9

To fix this you could try to:

  1. loosen the range of package versions you've specified
  2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

@sfc-gh-yixie
Copy link
Collaborator

what's in your requirements.txt?

@IRISDavidD
Copy link
Author

snowflake-connector-python

just to get this working

@sfc-gh-yixie
Copy link
Collaborator

A very old version (1.x) of python connector was being installed then an error was raised. The latest version is 3.6.0.
Do you know why such an old version was being installed?

@IRISDavidD
Copy link
Author

No idea I thought that was the case but was strange - I will try again and define the latest version

@IRISDavidD
Copy link
Author

ERROR: Could not find a version that satisfies the requirement snowflake-connector-python==3.6.0 (from versions: 1.4.5, 1.4.6, 1.4.7, 1.4.8, 1.4.9, 1.4.10, 1.4.11, 1.4.12, 1.4.13, 1.4.14, 1.4.15, 1.4.16, 1.4.17, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.6.8, 1.6.9, 1.6.10, 1.6.11, 1.6.12, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8, 1.7.9, 1.7.10, 1.7.11, 1.8.0, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5, 1.8.6, 1.8.7, 1.9.1)
ERROR: No matching distribution found for snowflake-connector-python==3.6.0

@IRISDavidD
Copy link
Author

IRISDavidD commented Jan 10, 2024

removed --platform manylinux2010_x86_64 and installs but this doesn't work in the lambda layer I get this error "Unable to import module 'lambda_function': /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /opt/python/cryptography/hazmat/bindings/_rust.abi3.so)"

@sfc-gh-yixie
Copy link
Collaborator

I haven't tried the lambda myself. Does this help? https://interworks.com/blog/2023/03/28/how-to-install-the-snowflake-python-connector-in-aws-lambda/

@IRISDavidD
Copy link
Author

I have 3.9 is working was hoping for a more updated python version.

@FreyGeospatial
Copy link

ERROR: Could not find a version that satisfies the requirement snowflake-connector-python==3.6.0 (from versions: 1.4.5, 1.4.6, 1.4.7, 1.4.8, 1.4.9, 1.4.10, 1.4.11, 1.4.12, 1.4.13, 1.4.14, 1.4.15, 1.4.16, 1.4.17, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.6.8, 1.6.9, 1.6.10, 1.6.11, 1.6.12, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8, 1.7.9, 1.7.10, 1.7.11, 1.8.0, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5, 1.8.6, 1.8.7, 1.9.1) ERROR: No matching distribution found for snowflake-connector-python==3.6.0

I'm having the same issue with python 3.11

@FreyGeospatial
Copy link

Even with 3.9, I get "Unable to import module 'lambda_function': /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /opt/python/cryptography/hazmat/bindings/_rust.abi3.so)"

@FreyGeospatial
Copy link

FreyGeospatial commented Jan 26, 2024

I have 3.9 is working was hoping for a more updated python version.

@IRISDavidD How did you get this working in 3.9?

@IRISDavidD
Copy link
Author

Reply no I haven't - still on 3.9 and upgrading all our snowflake lambdas to 3.9 from 3.8 before the depreciation date

@FreyGeospatial
Copy link

I haven't tried the lambda myself. Does this help? https://interworks.com/blog/2023/03/28/how-to-install-the-snowflake-python-connector-in-aws-lambda/

@sfc-gh-yixie unfortunately this does not work for me.

@sfc-gh-aling
Copy link
Collaborator

hey @IRISDavidD @FreyGeospatial , are you still observing the issue?

I would recommend you to try, inside your docker image, using Python >= 3.8 and only pip installing the latest connector first to see if connector alone works, and then we can gradually add back other dependencies back to see which are conflicts and how to resolve them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants