创建扩展 postgis 失败,

问题描述 投票:0回答:9

我正在

Ubuntu 18.04
psql (PostgreSQL) 12.2 (Ubuntu 12.2-2.pgdg18.04+1)

运行

temba=# create extension postgis;
失败并出现以下错误

ERROR:  could not open extension control file "/usr/share/postgresql/10/extension/postgis.control": No such file or directory

我运行

find /usr -name postgis.control
只是发现
postgis.control
位于名为
12
而不是
10

的文件夹中
laptop@xyz-x:~$ find /usr -name postgis.control
/usr/share/postgresql/12/extension/postgis.control

编辑1

我已经跑了

sudo apt-get install postgis

Reading package lists... Done
Building dependency tree       
Reading state information... Done
postgis is already the newest version (3.0.1+dfsg-2.pgdg18.04+1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
postgresql postgis
9个回答
22
投票

我运行了这个

sudo apt install postgis postgresql-10-postgis-2.5
并且成功了


10
投票

我不确定我需要什么版本的 postgres 或 postgis,所以我发现

sudo apt install postgis postgresql-postgis
有效。

它要么给了我最新的,要么与我安装的 postgres 版本匹配。



3
投票

我使用 Linux Mint,并且在 postgres10 上遇到了这个问题,并且还有:

could not access file "$libdir/postgis-2.4": No such file or directory
随后。安装特定扩展 脚本包为我解决了这个问题:

sudo apt install postgresql-10-postgis-2.4 postgresql-10-postgis-2.4-scripts Reading package lists... Done Building dependency tree        Reading state information... Done postgresql-10-postgis-2.4-scripts is already the newest version (2.4.3+dfsg-4). postgresql-10-postgis-2.4-scripts set to manually installed. The following NEW packages will be installed libprotobuf-c1 postgresql-10-postgis-2.4

然后转到 pgAdmin,

CREATE EXTENSION postgis;
成功返回。


2
投票

sudo apt install postgis postgresql-13-postgis-3
适用于 postgres 13.1 及更高版本
CREATE EXTENSION postgis;
(postgres 命令)


2
投票
  1. 进入postgis安装的文件位置;

    C:\Program Files\PostgreSQL 在

  2. 运行stackbuilder.exe

  3. 选择连接您的数据库;

  4. 选择“空间扩展”并安装


1
投票

或者,更简单的是,运行

sudo apt install postgis postgresql-12-postgis-2.5
for postgres12


0
投票

如果 CREATE EXTENSION postgis 无法正常工作并给出错误 no such file or directory。请按照以下步骤操作:

进入postgis安装的文件位置;

1.C:\Program Files\PostgreSQL 在 2.运行stackbuilder.exe; 3.选择连接您的数据库; 4.选择“Spatial Extensions”并安装

如果您的 stackbuilder 没有响应,请等待一段时间,尝试使用快速互联网连接。


0
投票

对于 PostgreSQL 14:

sudo apt install postgis postgresql-14-postgis-3
在 Ubuntu 20.04 上测试


0
投票

对于 RedHat/CentOs/Fedora 可以通过以下方式解决此问题

yum install postgresql13-contrib

参考:https://github.com/hapostgres/pg_auto_failover/issues/558

© www.soinside.com 2019 - 2024. All rights reserved.