2 Answers
- Newest
- Most votes
- Most comments
1
Create an Amazon Linux2 environment using the Dockerfile below.
FROM --platform=linux/x86_64 amazonlinux:2
ARG PYTHON_VERSION=3.12.1
RUN yum update -y && yum install -y tar gzip make gcc epel-release openssl11 openssl11-devel bzip2-devel libffi-devel \
&& curl https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz | tar xz \
&& export CFLAGS=$(pkg-config --cflags openssl11) && export LDFLAGS=$(pkg-config --libs openssl11) \
&& cd Python-${PYTHON_VERSION} && ./configure && make && make install \
&& cd - && rm -rf Python-${PYTHON_VERSION}
ADD entrypoint.sh /
RUN yum install -y zip \
&& mkdir /python \
&& chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
entrypoint.sh looks like this:
#!/bin/bash -eu
SRC=/python
DIST=/dist/layer.zip
pip3 install -t ${SRC} $@
rm -f ${DIST}
zip -q -r ${DIST} ${SRC}
Please build with the following command.
docker build . -t bundle-pip-modules-for-aws-lambda-layers:python3.12
Finally, create a layer using the following command.
Please write your required modules in requirements.txt.
Once layer.zip is completed, try registering it as a Lambda layer.
docker run --rm \
-v $(pwd)/requirements.txt:/requirements.txt \
-v $(pwd):/dist \
bundle-pip-modules-for-aws-lambda-layers:python3.12 \
-r requirements.txt
0
Hello.
Does the Python version of the environment where you created the langchain module layer match the Python version used by Lambda?
If they do not match, try creating a layer by matching the Python version of the layer creation environment and Lambda.
Both python version are same 3.12
Relevant content
- asked a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 3 months ago
I did something similar which 1/2 manual steps but Im going to borrow this @Riku :-). Thanks