Setting up Shapely on AWS Lambda Python functions

前端 未结 2 1305
长情又很酷
长情又很酷 2021-01-25 00:22

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         


        
相关标签:
2条回答
  • 2021-01-25 01:17

    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

    0 讨论(0)
  • 2021-01-25 01:22

    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!

    0 讨论(0)
提交回复
热议问题