I am trying to use the LXML module within AWS Lambda and having no luck. I downloaded LXML using the following command:
pip install lxml -t folder
The lxml library is os dependent thus we need to have precompiled copy. Below are the steps.
Create a docker container.
docker run -it lambci/lambda:build-python3.8 bash
Create a dir named 'lib'(anything you want) and Install lxml into it.
mkdir lib
pip install lxml -t ./lib --no-deps
Open another cmd and run
docker ps
copy the containerid
Copy the files from container to host.
mkdir /home/libraries/opt/python/lib/python3.8/site-packages/
docker cp
Now you have lxml copy of files compiled from amazonlinux box, If you like to have lxml as Lambda layer. Navigate to /home/libraries/opt
and zip the folder named python
. Now you can attach the zip in your lambda as layer.
If you want lxml library inside lambda. Navigate to /home/libraries/opt/python/lib/python3.8/site-packages/
and copy the lxml
folder in your lambda.