Python-zeep: lxml not supported in AWS Lambda server-less framework

Created on 24 Jan 2018  路  6Comments  路  Source: mvantellingen/python-zeep

I did read the guidelines for filing bug reports but this one is cross-version, all code affected.

Basically, I am interested in running an AWS Lambda function that implements the zeep library, however, there is no straight forward way to utilize the lxml library in AWS Lambda. See this StackOverflow thread for more context, but it has to do with the shared libraries for lxml not being present in AWS Lambda during runtime. There are some pretty hacky solutions and work arounds but in my mind, best keep Lambda simple as possible since that's precisely one of the things its for.

The one answer that does intrigue me from that thread is using Python's builtin xml instead of lxml. I was looking to play with a pull request, but hit an immediate blocker on syntax errors in zeep.ansyncio.transports under Python3.6, when I pulled the current master.

Can anyone think of any reason to not attempt this switch? Is there a current branch or tag I should be originating from in terms of operating under Python3.6?

Most helpful comment

All 6 comments

I also have encountered this problem last year, just to make my code run in lambda I installed lxml on an EC2 instance, download it and use it to replace the original lxml on my site-packages folder.

The built-in xml lib in python doesn't support namespaces (properly) so that is a no-go. So let's hope that an lambda compatible lxml is released.

I have to consider this out of scope for this project, so i'm closing it

I came across this problem using Python 3.7 in Lambda. Switching to 3.6 solved my problem at least.

fixed this by using https://github.com/UnitedIncome/serverless-python-requirements and dockerizePip: true, running Python3.8 and lxml 4.4.2

Reverting to 3.6 is not an option for me as I depend on dataclasses.

It seems that @ejdoh1 's suggestion would work, or this: https://stackoverflow.com/questions/56818579/unable-to-import-lxml-etree-on-aws-lambda

Was this page helpful?
0 / 5 - 0 ratings