【问题标题】:Cannot install Postgis on Heroku CI无法在 Heroku CI 上安装 Postgis
【发布时间】:2021-09-17 22:44:18
【问题描述】:

在 Heroku 中部署我的应用以进行测试时出现以下错误:

self = <django.db.backends.utils.CursorWrapper object at 0x7f634cc50a00>
sql = 'CREATE EXTENSION IF NOT EXISTS postgis', params = None
ignored_wrapper_args = (False, {'connection': <django.contrib.gis.db.backends.postgis.base.DatabaseWrapper object at 0x7f635095d2b0>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f634cc50a00>})
    def _execute(self, sql, params, *ignored_wrapper_args):
        self.db.validate_no_broken_transaction()
        with self.db.wrap_database_errors:
            if params is None:
                # params default might be backend specific.
>               return self.cursor.execute(sql)
E               django.db.utils.OperationalError: could not open extension control file "/app/.indyno/vendor/postgresql/share/extension/postgis.control": No such file or directory
.heroku/python/lib/python3.9/site-packages/django/db/backends/utils.py:82: OperationalError

我的 app.json 文件中有以下代码:

{
  "buildpacks": [
    {
      "url": "https://github.com/heroku/heroku-geo-buildpack.git"
    },
    {
      "url": "heroku/python"
    }
  ],
  "environments": {
    "test": {
      "addons": [
        "heroku-postgresql:in-dyno"
      ],
      "scripts": {
        "test": "pytest"
      }
    }
  }
}

从我的结论来看,我看到错误是在执行 SQL 命令'CREATE EXTENSION IF NOT EXISTS postgis' 时发生的。

【问题讨论】:

  • 错误显示"/app/.indyno/vendor/postgresql/extension/postgis.control" No such file or directory 这可能意味着您必须安装一些模块或库。或者,也许您必须创建一些文件夹。
  • @furas 通过添加 PostGIS buildpack 并使用 postgresql 版本 11 找到了解决方案。

标签: django database postgresql heroku postgis


【解决方案1】:

在深入寻找解决方案后,我添加了以下 buildpack: https://github.com/riskmethods/heroku-buildpack-ci-postgis

虽然这仍然引发了错误; psycopg2.errors.UndefinedFile: could not load library "/app/.indyno/vendor/postgresql/lib/postgis-2.5.so": /app/.indyno/vendor/postgresql/lib/postgis-2.5.so: undefined symbol: AllocSetContextCreateExtended。可以通过使用 PostgreSQL 版本 11 来解决。我将 app.json 文件更改为:

{

  "environments": {
    "test": {
      "buildpacks": [
        {
          "url": "https://github.com/heroku/heroku-geo-buildpack.git"
        },
        {
          "url": "heroku/python"
        },
        {
          "url": "https://github.com/riskmethods/heroku-buildpack-ci-postgis"
        }
      ],
      "env": {
        "POSTGRESQL_VERSION": "11"
      },
      "addons": [
        "heroku-postgresql:in-dyno"
      ],
      "scripts": {
        "test": "pytest"
      }
    }
  }
}

【讨论】:

    猜你喜欢
    • 2022-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-07
    • 2014-12-02
    • 2017-12-24
    • 2020-10-28
    • 1970-01-01
    相关资源
    最近更新 更多