I have a tried to setup Shapely on AWS Lambda
but was getting the below error always.
module initialization error: Could not find lib geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so', '/usr/lib/libgeos_c.so'].
Not sure how to build shapely
in this case. Have built my package on Linux
instance and have used the same for deployment purpose.
If you wish to build your own Lambda compatible binaries for use in your Deployment packages, AWS states the AMI needed to build them here:
https://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html
I have created an EC2 instance with that specific AMI and then used pip to install the packages I needed into a target folder -t
. Once complete I simply tar'd that up and used it as the basis for my deployment package and it worked.
Alternatively I have downloaded from : https://github.com/ryfeus/lambda-packs and copied the packages I have needed. (Which in the case of shapley, was the shapely and shapely-1.6b4.dist-info directories.
I believe these are only built for Python 2.7 at the moment, and I have only compiled binaries with the above AMI for Python 2.7.
HTH
I hit this same issue, and was able to set up to build a layer for use in Lambda. I wrote it up as an open source package here https://github.com/bearflagrobotics/libgeos-lambda-build using Docker to build the binary distribution. You can just drop that in as a layer for your lambda function and run any version of Shapely or Python you want!
来源:https://stackoverflow.com/questions/48190029/setting-up-shapely-on-aws-lambda-python-functions