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?

pibo
已提问 1 个月前189 查看次数
1 回答
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
已回答 1 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则

相关内容