Unable to import lxml etree on aws lambda

后端 未结 2 1824
没有蜡笔的小新
没有蜡笔的小新 2021-01-18 10:08
{
  \"errorMessage\": \"Unable to import module \'lambda_function\': 
        cannot import name   \'etree\' from \'lxml\' (/var/task/lxml/__init__.py)\",
  \"errorT         


        
2条回答
  •  轮回少年
    2021-01-18 10:33

    I came across a similar problem and I figured out one quick workaround

    Using pre-compiled build of lxml

    Download https://github.com/shubh2502/aws-lambda-lxml

    1. Folder 3.6.4 and 3.8.0 are lxml versions
    2. Inside lxml there are two builds python27 and python36

    3. As per AWS Lambda python version choose either one of them

    4. Inside python27 and python36 there is lxml folder

    5. Zip code with lxml folder and make sure python has the same version

    6. In Case of AWS Lambda layer put lxml folder into this structure -

      python/lib/python3.6/site-packages

    I spent lots of time in docker and building these stuff, this method was savior for me, I hope this will help you out

提交回复
热议问题