Search code examples
pythonaws-lambda

error while uploading python zip file with psycopg2 to aws lambda


I'm trying to add the python zip files to was lambda which contains psycopg2 files in it.I'm getting an error. please try to help

  "errorMessage": "Unable to import module 'handler': libpq.so.5: cannot open shared object file: No such file or directory",
  "errorType": "Runtime.ImportModuleError"

Solution

  • The point is psycopg2 depends on native code (libpq.so) and your zip file does not contain this dependency.

    See here for a solution

    Another option is pip install psycopg2-binary. See here for details.