Heroku:django.核心.异常.配置不正确:找不到GDAL

oaxa6hgo  于 2022-11-13  发布在  Go
关注(0)|答案(2)|浏览(107)

我尝试在heroku上运行geodjango应用程序,并添加了构建包以使gdal可用
https://github.com/cyberdelia/heroku-geo-buildpack.git。在推送过程中,表示已成功安装gdal和其他地理工具

remote: -----> geos/gdal/proj app detected
remote:        Using geos version: 3.6.1
remote:        Using gdal version: 2.1.3
remote:        Using proj version: 4.9.3
remote: -----> Vendoring geo libraries done
remote: -----> Python app detected
remote:  !     The latest version of Python 3 is python-3.6.4 (you are using python-3.6.2, which is unsupported).
remote:  !     We recommend upgrading by specifying the latest version (python-3.6.4).
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing requirements with pip
remote:
remote: -----> $ python manage.py collectstatic --noinput
remote:        1018 static files copied to '/tmp/build_2e0a13e9519778105269a34/test/staticfiles', 1158 post-processed.
remote:
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 235.8M
remote: -----> Launching...
remote:        Released v60
remote:        https://test.herokuapp.com deployed to Heroku
remote:
remote: Verifying deploy... done.

当我请求页面时,它说应用程序错误。
heroku logs开始

2018-03-19T14:25:00.614100+00:00 app[web.1]:     from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
2018-03-19T14:25:00.614103+00:00 app[web.1]:     from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
2018-03-19T14:25:00.614104+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/gis/gdal/libgdal.py", line 43, in <module>
2018-03-19T14:25:00.614106+00:00 app[web.1]:     % '", "'.join(lib_names)
2018-03-19T14:25:00.614813+00:00 app[web.1]: [2018-03-19 14:25:00 +0000] [9] [INFO] Worker exiting (pid: 9)
2018-03-19T14:25:00.746744+00:00 app[web.1]: [2018-03-19 14:25:00 +0000] [4] [INFO] Shutting down: Master
2018-03-19T14:25:00.746839+00:00 app[web.1]: [2018-03-19 14:25:00 +0000] [4] [INFO] Reason: Worker failed to boot.
2018-03-19T14:25:00.614110+00:00 app[web.1]: 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.>

我应该在设置中指定一些路径还是可能我正在使用不兼容的版本?(我正在使用Django==2.0.2

7fhtutme

7fhtutme1#

从Heroku的文档中,将以下内容添加到settings.py:

import dj_database_url
DATABASES['default'] =  dj_database_url.config()
DATABASES['default']['ENGINE'] = 'django.contrib.gis.db.backends.postgis'

GDAL_LIBRARY_PATH = os.getenv('GDAL_LIBRARY_PATH')
GEOS_LIBRARY_PATH = os.getenv('GEOS_LIBRARY_PATH')
k4aesqcs

k4aesqcs2#

以下是如何在Heroku应用中包含gdal的正确Heroku Documentation。简单地说,在Django应用根目录中:

1.  Create an empty file called Aptfile
2.  In that file, include the line `gdal-bin` and save

然后道:

$ git add Aptfile  
$ git commit -m "Add apt dependency"
$ git push heroku master

这应该有gdal运行和可访问的你的dyno。

相关问题