首页 > 解决方案 > 使用 Zappa 将 Geo Django 项目添加到 AWS Lambda。获取 OSError:无法打开共享对象文件:没有这样的文件或目录

问题描述

我正在尝试将我的 Geo-Django 应用程序部署到 Zappa 1st 我得到

django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library 
(tried "gdal", "GDAL", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0", "gdal1.11.0", 
"gdal1.10.0", "gdal1.9.0"). Is GDAL installed? If it is, try setting 
GDAL_LIBRARY_PATH in your settings.

然后我点击此链接并添加了以下内容

我在我的 AWS Lambda 控制台中设置了这些环境变量:

"LD_LIBRARY_PATH": "/tmp/code/lib/",
"PROJ_LIB": "/tmp/code/lib/proj4/",

在我的(Django)应用程序的设置文件中,我设置:

GDAL_LIBRARY_PATH = "/tmp/code/lib/libgdal.so.20.1.3"
GEOS_LIBRARY_PATH = "/tmp/code/lib/libgeos_c.so.1"

现在我收到错误

OSError: /tmp/code/lib/libgdal.so.20.1.3: cannot open shared object file: No such file or directory

我怎样才能解决这个问题 ?

我所做的总结

$ pip install zappa
$ zappa init
$ zappa deploy prod

下面是我的 zappa_settings.json

{
    "prod": {
        "aws_region": "us-east-1",
        "django_settings": "Cool.settings",
        "profile_name": "default",
        "project_name": "cool",
        "runtime": "python3.6",
        "s3_bucket": "coolplaces-t47c5adgt",
        "extra_permissions": [{
            "Effect": "Allow",
            "Action": ["rekognition:*"],
            "Resource": "*"
        }]
    }
} 

标签: djangopython-3.xaws-lambdazappa

解决方案


我假设您已将两个必需的库捆绑到您的 Lambda 部署包中。

在 Lambda 容器中,它被提取到/var/task目录中。该目录已经在LD_LIBRARY_PATH. 尝试将其他必要的 ENVVARS 也设置/var/task为。


推荐阅读