Error when importing library dependencies added to a layer

0

Hello, I am currently developing an astrology portal that will use AWS lambdas to create astral maps. Initially, after a research stage I found the kerykeion lib written in Python, which met all my client's prerequisites, to perform this function in aws lambda, a layer needs to be created, ok, I created the layer and uploaded it to aws... but, when importing the function, I am receiving the following error

"errorMessage": "Unable to import module 'lambda_function': No module named 'swisseph'"

What can be done to test function compatibility? Would it be better for me to go with another alternative?

1 Resposta
0

Hi,

You can use AWS SAM CLI tools to create a simple Python Lambda function, build, and invoke it locally to confirm that everything works as expected and you have all 3rd-party library dependencies installed. See Test your application locally for more details.

In general, you don't necessarily need a layer to call additional libraries from your Lambda function. All you need is have them deployed together with your Lambda function handler. Creating a .zip deployment package with dependencies provides an example how to create a zip archive with all dependencies included.

Make sure that your Lambda deployment (or Lambda layer) includes ALL required libraries. For example, if your script references kerykeion library, which itself depends on a swisseph library that has not been deployed with the Lambda handler, - it will fail with the error that you reported.

Kind regards,

AWS
respondido há um mês

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas