question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to use on AWS Lambda

See original GitHub issue
  1. What version of Python are you using (python --version)?

Tried 3.6.7 and 3.7.1

  1. What operating system and processor architecture are you using (python -c 'import platform; print(platform.platform())')?

Building distribution on Linux-4.15.0-1035-aws-x86_64-with-Ubuntu-18.04-bionic,

Running on AWS Lambda (Linux-4.14.133-88.105.amzn1.x86_64-x86_64-with-glibc2.2.5)

  1. What are the component versions in the environment (pip list)?

Package Version


asn1crypto 0.24.0 azure-common 1.1.23 azure-storage-blob 2.1.0 azure-storage-common 2.1.0 boto3 1.9.210 botocore 1.12.210 certifi 2019.6.16 cffi 1.12.3 chardet 3.0.4 Click 7.0 cryptography 2.7 docutils 0.15.2 fsspec 0.4.1 future 0.17.1 idna 2.8 ijson 2.4 jmespath 0.9.4 numpy 1.17.0 pandas 0.25.0 pip 19.2.2 pycparser 2.19 pycryptodomex 3.8.2 PyJWT 1.7.1 pyOpenSSL 19.0.0 python-dateutil 2.8.0 python-lambda 3.2.6 pytz 2019.2 PyYAML 5.1.2 requests 2.22.0 s3fs 0.3.3 s3transfer 0.2.1 setuptools 41.1.0 six 1.12.0 snowflake-connector-python 1.8.7 snowflake-sqlalchemy 1.1.14 SQLAlchemy 1.3.7 urllib3 1.25.3 wheel 0.33.6

  1. What did you do?
import pandas as pd 
from sqlalchemy import create_engine

db_string = "snowflake://{}:{}@{}/{}/{}?warehouse={}?role={}".format(
            user, password, account, db, schema, warehouse, role
        )
engine = create_engine(db_string)
conn = engine.connect() 
  1. What did you expect to see? I expect to see no errors with a successful connection. I then pass the conn object to a pd.to_sql() method.

  2. What did you see instead?

No module named ‘snowflake.sqlalchemy’

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

lambda_logs.txt

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
smtakedacommented, Sep 16, 2019

There is known issue with the namespace package, e.g., snowflake, which is not recognized by the lambda. The workaround is add __init__.py to the directory.

0reactions
kychanbpcommented, Oct 14, 2020

I get the same error in aws glue

Traceback (most recent call last):
  File "/tmp/runscript.py", line 123, in <module>
    runpy.run_path(temp_file_path, run_name='__main__')
  File "/usr/local/lib/python3.6/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/usr/local/lib/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/glue-python-scripts-x20ytvw9/ETL_job_cainiao_supply_chain.py", line 332, in <module>
  File "/tmp/glue-python-scripts-x20ytvw9/ETL_job_cainiao_supply_chain.py", line 80, in main
  File "/glue/lib/installation/sqlalchemy/engine/__init__.py", line 500, in create_engine
    return strategy.create(*args, **kwargs)
  File "/glue/lib/installation/sqlalchemy/engine/strategies.py", line 61, in create
    entrypoint = u._get_entrypoint()
  File "/glue/lib/installation/sqlalchemy/engine/url.py", line 172, in _get_entrypoint
    cls = registry.load(name)
  File "/glue/lib/installation/sqlalchemy/util/langhelpers.py", line 251, in load
    return self.impls[name]()
  File "/glue/lib/installation/sqlalchemy/util/langhelpers.py", line 274, in load
    mod = compat.import_(modulepath)
ModuleNotFoundError: No module named 'snowflake.sqlalchemy'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/runscript.py", line 142, in <module>
    raise e_type(e_value).with_traceback(new_stack)
  File "/tmp/glue-python-scripts-x20ytvw9/ETL_job_cainiao_supply_chain.py", line 332, in <module>
  File "/tmp/glue-python-scripts-x20ytvw9/ETL_job_cainiao_supply_chain.py", line 80, in main
  File "/glue/lib/installation/sqlalchemy/engine/__init__.py", line 500, in create_engine
    return strategy.create(*args, **kwargs)
  File "/glue/lib/installation/sqlalchemy/engine/strategies.py", line 61, in create
    entrypoint = u._get_entrypoint()
  File "/glue/lib/installation/sqlalchemy/engine/url.py", line 172, in _get_entrypoint
    cls = registry.load(name)
  File "/glue/lib/installation/sqlalchemy/util/langhelpers.py", line 251, in load
    return self.impls[name]()
  File "/glue/lib/installation/sqlalchemy/util/langhelpers.py", line 274, in load
    mod = compat.import_(modulepath)
ModuleNotFoundError: No module named 'snowflake.sqlalchemy'

How can I solve it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot deployment issues in Lambda
This issue can occur when you specify an Amazon S3 object in a call to UpdateFunctionCode, or use the package and deploy commands...
Read more >
Troubleshooting AWS Lambda identity and access
Use the following information to help you diagnose and fix common issues that you might encounter when working with Lambda and IAM.
Read more >
Troubleshoot invocation issues in Lambda
This error can occur if your AWS Key Management Service (AWS KMS) key is disabled, or if the grant that allows Lambda to...
Read more >
Troubleshoot networking issues in Lambda
Network connectivity errors can result from issues with your VPC's routing configuration, security group rules, AWS Identity and Access Management (IAM) role ...
Read more >
AWS Lambda function errors in Python
This page describes how to view Lambda function invocation errors for the Python runtime using the Lambda console and the AWS CLI.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found