Home>

I want to create a Python deployment package on AWS Lambda in a Windows environment

Problem i am experiencing

lxml is not recognized

Error message

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml.Do you need to install a parser library?
Applicable source code
BeautifulSoup (res.text, "lxml")

https://docs.aws.amazon.com/en_us/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html
Using this as a reference, create a package as follows

requirements.txt

PyMySQL
requests
bs4
lxml
mkdir -p package
cd package;py -m pip install -r ../requirements.txt --target.
cd package;zip -r9 ../deploy.zip pymysql requests chardet certifi idna bs4 soupsieve lxml


Make a package with

zip -g deploy.zip lambda_function.py settings.py
aws lambda update-function-code --function-name xxxxx --zip-file fileb: //deploy.zip


Deploy with

Is pip install on Windows?

Collecting lxml == 4.4.1
  Using cached https://files.pythonhosted.org/packages/32/b0/0789ab7849fc55443eb6c87d866b10fb211d3c65c4cbc597bcf5d967a9a9/lxml-4.4.1-cp38-cp38-win_amd64.whl


I wonder if it's because the thing for Windows and Windows has been installed
Is there a way to install lxml for Amazon Linux on windows

Supplemental information (FW/tool version etc.)

Development environment is on Windows7 64bit MSYS
Lambda is python 3.7

  • Answer # 1

    >Using cached https://files.pythonhosted.org/packages/32/b0/0789ab7849fc55443eb6c87d866b10fb211d3c65c4cbc597bcf5d967a9a9/lxml-4.4.1-cp38-cp38-win_amd64.whl

    Because I search with lxml whl

    https://pypi.org/project/lxml/#files

    Since I got to a place called

    Instead of lxml in requirements.txt

    https://files.pythonhosted.org/packages/e7/a8/40115c84414c017e1a293f331709eb7534303d3ccd11ef805ac09b1481e7/lxml-4.4.1-cp37-cp37m-manylinux1_x86_64.whl

    The URL

    was installed successfully for Linux
    It worked even after Lambda deployment

    I don't know whl well
    Is it like a package for pip install ...

    Reference: https://aws.amazon.com/premiumsupport/knowledge-center/lambda-python-package-compatible/