我想在 heroku 中部署我的应用程序。我使用的平台是django 1.11、django-rest-framework、postgresql、gis
。当我执行 git push heroku master
时,出现以下错误
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "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.
它说要安装 GDAL 并提供 GDAL_LIBRARY_PATH。我如何提供它的路径?
我也配置了postgresql
heroku addons:create heroku-postgresql:hobby-dev
最佳答案
我遇到了同样的问题,不得不从几个地方拼凑信息。
首先,来自官方 Heroku 文档:https://devcenter.heroku.com/articles/postgis#geodjango-setup将这些行添加到您的设置中:
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')
同时将 django.contrib.gis
添加到您的 INSTALLED_APPS
。
为您的应用运行 heroku config:set BUILD_WITH_GEO_LIBRARIES=1 -a name_of_your_app
。
最后,但重要的是,运行 heroku buildpacks:add https://github.com/TrailStash/heroku-geo-buildpack -a name_of_your_app
这适用于 heroku-16 堆栈。
关于django - 由于 gdal 库,heroku push 被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45271859/