ZZzzZZzz
ZZzzZZzz

Reputation: 1844

Setting up Shapely on AWS Lambda Python functions

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.

Upvotes: 2

Views: 1797

Answers (2)

Daniel
Daniel

Reputation: 160

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!

Upvotes: 4

Graeme
Graeme

Reputation: 1698

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

Upvotes: 4

Related Questions