0

Getting the following error on testing AWs lambda created by uploading zip. "errorMessage": "Unable to import module 'lambda_function': No module named 'pydantic_core'"

zip is created on macOS. I can see that it has downloaded a wheel pydantic_core-2.16.2-cp311-cp311-macosx_10_12_x86_64.whl. Is this an issue?

How to ensure that I have the correct wheel compatible with AWS lambda.

1 Answer 1

0

NOTE: This was done on windows and it seems like you are on Mac but going through different processes and answers from other people it seemed like the same steps.

Just ran into something like this myself and figured I'd throw out an answer even though its late. The recommended solution for importing modules is to use layers. That worked best for me included. Package your modules like so

package.zip
|_python (Has to have this python folder with module(s) inside)
  |_pydantic
  |_pydantic.version.dist

Then go to Lambda > Layers > Create layer, name and describe your layer. Upload the whole zip file. Pick your architecture and runtime (mandatory even though it says optional). After creating the layer, go to your lambda function and attach the layer by going to Code > Layers > Add a Layer, then choose add a custom layer and pick the layer you just created.

Hope it works/you already figured out the problem!

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

1 Comment

Conciseness: Provides direct, actionable steps. Formatting: Uses proper code blocks, headings, and clear structure. References: Includes links to relevant AWS documentation. Relevance: Focuses solely on resolving the stated issue.

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.