django - 使用 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": "*"
}]
}
}
解决方案
我假设您已将两个必需的库捆绑到您的 Lambda 部署包中。
在 Lambda 容器中,它被提取到/var/task
目录中。该目录已经在LD_LIBRARY_PATH
. 尝试将其他必要的 ENVVARS 也设置/var/task
为。
推荐阅读
- spring-cloud-stream - 如何使 Spring Cloud Stream 中流中未处理异常的控制台输出静音?
- python - 如何确认一个文件中的某些子字符串是否包含在另一个文件中?
- r - 使用wellPanel时为闪亮的数据表添加滚动条
- ruby-on-rails - 如何使用 minimagick 编辑上传的图像,该图像被上传到 active_storage?
- c++ - 我是否需要使用 Gstreamer 构建 OpenCV 才能在 OpenCV 中使用 Gstreamer
- javascript - 如何验证角度 6 中的多维数组值?
- c# - Task.WhenAll 与 LINQ 选择
- python - 如何使用 Tkinter 在 FigureCanvasTkAgg 内的 Plot 上绘制一个矩形?
- jenkins - 将更改推送到特定分支时不会触发多分支管道
- java - 我想阅读一个实时日志文件并想搜索我在运行时创建的一些特定关键字