1

I am trying to run python code in AWS lambda and I got exception from aws lambda when I run test.

I don't understand what type of this exception. its first time for me.

 {
  "errorMessage": "The 'psycopg2>=2.5' distribution was not found and is required by the application",
  "errorType": "DistributionNotFound",
  "stackTrace": [
    [
      "/var/task/redshift_test.py",
      22,
      "handler",
      "print_meta_info('test_schema')"
    ],
}

here is my list of python3.6 library for run code.

.
├── redshift_sqlalchemy
├── sqlalchemy
├── SQLAlchemy-1.2.8.egg-info
├── sqlalchemy_redshift
└── sqlalchemy_redshift-0.7.1.dist-info

>> when I try pip freeze
psycopg2==2.7.5
SQLAlchemy==1.2.8
sqlalchemy-redshift==0.7.1
1
  • I just update for your question and seems installed Commented Jun 26, 2018 at 18:06

1 Answer 1

4

Psycopg2 is not a module that is available when executing Lambda functions in AWS. In fact, Lambda does not include ANY libraries in its AMI to communicate with a PostGreSQL database. In order to run the psycopg2 library, you will need to compile the C psycopg2 library code, reference it in a python file, zip it with your lambda function, and upload it to either S3 or Lambda directly.

Fortunately, some kind soul on the internet has already done this :) You can find his code here https://github.com/jkehler/awslambda-psycopg2.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.