I'm trying to create a lambda layer that includes pydantic/pydantic_core (Lambda python 3.11, x86_64) but getting the following error: "Unable to import module 'reddit_lambda': No module named 'pydantic_core._pydantic_core'"
For context, I'm installing this on a windows x64 machine.
From reading up about it here, here and here, it seems that pip installing pydantic for an incompatible architecture (win_amd64).
Install log:
Using cached pydantic-2.4.2-py3-none-any.whl (395 kB)
Using cached pydantic_core-2.10.1-cp311-none-win_amd64.whl (2.0 MB)
My question: Is there a way to force pip to install packages into a directory for a specific architecture in powershell?
I saw an old discussion here, that this is possible for Linux but not sure how to do it on powershell.
FYI: I also tried adding pydantic_core from binary (tried pydantic_core-2.10.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
and pydantic_core-2.10.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
) but I'm a bit confused about which version to choose?
It is possible as part of the options provided by the pip
CLI.
For example given a requirements.txt
file containing the necessary dependencies, you can run:
# Create layer based on requirements.txt in python/ directory
pip install -r requirements.txt --platform manylinux2014_x86_64 --target ./python --only-binary=:all:
This command will create a directory named python
that will contain the packages downloaded to satisfy the requirements in the requirements.txt
file for the manylinux2014_x86_64
platform.
You can change the value provided to the --platform
flag according to your needs, you can see examples of available platforms in the examples here