I am trying to write an AWS python Lambda function that uses Shapely for simple point in polygon operations. I deployed an AWS linux EC2 instance, installed Shapely, and worked with the script. Then I downloaded linux specific libgeos_c.so.1 from my EC2 instance and linked it (through a server without a server) to exist in the same directory as my lambda function. However, after the deployment, the script will not be executed because it gives the error "I can not find the library or load any version of it ...". I even tried to explicitly specify the path libgeos_c.so.1 through the GEOS_LIBRARY_PATH environment variable so as not to affect. Is it impossible?
Here is a piece of code that sets an environment variable, and then calls a secondary script that actually imports and uses a beautiful shape.
import sys
import os
import subprocess
here = os.path.dirname(os.path.realpath(__file__))
site_pkgs = os.path.join(here, "venv", "lib", "python2.7", "site-packages")
sys.path.append(site_pkgs)
import json
def hello(event, context):
command = "GEOS_LIBRARY_PATH={} python test_geo_worker.py".format(here + "/libgeos_c.so.1")
foo = subprocess.check_output(command, shell=True)
print foo
Is there anyone who successfully deploys in lambda? My backup plan is to get back to good old postgres / postgis instead of slim, but I would like to try building this on the dynamo / lambda stack.
source
share