Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

536
Views
psycopg2 does not work with Serverless framework deployment on AWS Lambda

I am trying to make a lambda function connect to Redshift, and deploy the same via The Serverless Framework.

serverless.yml config:

pythonRequirements:
    dockerizePip: non-linux
    dockerFile: ./Dockerfile

Dockerfile:

FROM lambci/lambda:build-python3.6
RUN yum install -y postgresql-devel postgresql-libs

requirements.txt

psycopg2==2.8.5
requests==2.22.0
boto3==1.9.234

Deployment is done via:

sls deploy --function fn_name --force

AWS Lambda gives an error:

libpq.so.5: cannot open shared object file: No such file or directory

And I can confirm that it is missing, but when I test the same with local docker image, the file is present. I'm still unsure on how serverless actually deploys the package

I do not want to use psycopg2-binary and I'm still unsure about aws-psycopg2, any suggestions on how to get the code to run?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can try using this module instead of default one (Supports only Python3.x)

https://pypi.org/project/aws-psycopg2/

While the above is not actively maintained, and has the max version as psycopg2==2.8.4, it could serve the use-case you might have.

You can also try zipping and uploading the package from here https://github.com/jkehler/awslambda-psycopg2 if you need support for older python versions.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!