postgresql 尝试在 Postgres 中使用 PostGIS:“错误:无法打开扩展控制文件”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23726528/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:27:11  来源:igfitidea点击:

Trying to use PostGIS with Postgres: "ERROR: could not open extension control file"

postgresqlpostgisgeodjango

提问by Richard

I've just installed Postgres 9.3.4 and PostGIS 2.1 on OSX Mavericks using the very latest versions of the KyngChaos libraries.

我刚刚使用最新版本的KyngChaos 库在 OSX Mavericks 上安装了 Postgres 9.3.4 和 PostGIS 2.1 。

However, when I try to create spatial extensions on a database, I can't, because Postgres claims not to be able to see the extension file:

但是,当我尝试在数据库上创建空间扩展时,我不能,因为 Postgres 声称无法看到扩展文件:

:~ anna$ psql -d land -c "CREATE EXTENSION postgis;"
ERROR:  could not open extension control file 
"/usr/local/Cellar/postgresql/9.3.4/share/postgresql/extension/postgis.control": 
No such file or directory

It looks as though the file is located somewhere else:

看起来该文件位于其他地方:

:~ anna$ mdfind postgis.control
/usr/local/pgsql-9.3/share/extension/postgis.control

I'm definitely using the expected version of Postgres, although I don't know if this is where the KyngChaos libraries usually install to:

我肯定在使用 Postgres 的预期版本,尽管我不知道 KyngChaos 库是否通常安装到这里:

Annas-MacBook-Air:~ anna$ psql --version
psql (PostgreSQL) 9.3.4
Annas-MacBook-Air:~ anna$ which psql
/usr/local/pgsql-9.3/bin/psql

I've been quite careful not to install Postgres using Homebrew etc because I know that it can cause problems having multiple versions of the same system.

我一直非常小心,不使用 Homebrew 等安装 Postgres,因为我知道它会导致同一系统的多个版本出现问题。

Can anyone advise on why the extension file isn't in the expected place?

谁能建议为什么扩展文件不在预期的位置?



UPDATE:

更新:

It looks like perhaps there are multiple versions of Postgres floating around on my system, and I'm using the wrong one?

看起来我的系统上可能有多个版本的 Postgres,而我使用的是错误的版本?

:~ anna$ mdfind -name "postgres" | grep -G "postgres$"
/usr/local/pgsql-9.3/bin/postgres
/usr/local/var/postgres
/usr/local/Cellar/postgresql/9.3.4/bin/postgres

Which one should I be using, and how can I set the system to use this one by default?

我应该使用哪一个,以及如何将系统设置为默认使用这个?



FURTHER UPDATE

进一步更新

Here's the output of pg_config:

这是输出pg_config

BINDIR = /usr/local/pgsql-9.3/bin
DOCDIR = /usr/local/pgsql-9.3/share/doc
INCLUDEDIR = /usr/local/pgsql-9.3/include
PKGINCLUDEDIR = /usr/local/pgsql-9.3/include
INCLUDEDIR-SERVER = /usr/local/pgsql-9.3/include/server
LIBDIR = /usr/local/pgsql-9.3/lib
PKGLIBDIR = /usr/local/pgsql-9.3/lib
LOCALEDIR =
MANDIR = /usr/local/pgsql-9.3/man
SHAREDIR = /usr/local/pgsql-9.3/share
SYSCONFDIR = /usr/local/pgsql-9.3/etc
PGXS = /usr/local/pgsql-9.3/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--with-openssl' '--with-pam' '--with-krb5' '--with-gssapi' '--with-ldap' '--enable-thread-safety' '--with-bonjour' '--with-python' '--without-perl' '--enable-nls' '--with-libxml' 'CC=clang' 'CXX=clang++' 'CFLAGS=-Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -D_FILE_OFFSET_BITS=64' 'LD=clang' 'LDLFAGS=-arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk'
CC = gcc
CPPFLAGS = -I/usr/include/libxml2
CFLAGS = -Os -arch x86_64 -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -fwrapv
CFLAGS_SL =
LDFLAGS = -arch x86_64 -Wl,-dead_strip_dylibs
LDFLAGS_SL =
LIBS = -lintl -liconv -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -ledit -lz
VERSION = PostgreSQL 9.3.4

回答by John Moutafis

Searching a bit around I found this GISTwhere user jordanmkonczgives a solution for OSX:

搜索了一下,我发现了这个 GIST,其中用户jordanmkoncz为 OSX 提供了一个解决方案:

  1. Use homebrew to install PostGIS.
  2. You need to be careful because brew will install the latest available version of PostGIS which may not be compatible with your specific version of PostgreSQL. Here is a compatibility tablefor your convenience.
  1. 使用自制软件安装 PostGIS。
  2. 您需要小心,因为 brew 将安装最新的 PostGIS 可用版本,该版本可能与您的特定 PostgreSQL 版本不兼容。为了您的方便,这里有一个兼容性表


To install a specific version of PostGIS (or any other formula) jordnmkonczrecommends using this method: Homebrew install specific version of formula?for installing spec

要安装特定版本的 PostGIS(或任何其他公式),jordnmkoncz建议使用此方法:Homebrew 安装特定版本的公式?用于安装规范

I had the same problem with Linux Mint (Ubuntu like) which I solve following this gis.stackexchange thread.

我在 Linux Mint(类似 Ubuntu)上遇到了同样的问题,我按照这个gis.stackexchange thread解决了这个问题

回答by gb96

You need to also install postgis-scriptsas included in the following, which solved the same issue for me: StackOverflow Answer

您还需要安装以下包含的postgis-scripts,这为我解决了同样的问题: StackOverflow Answer

回答by Dotan

What (finally) solved it for me was to uninstall postgis and install it again from http://postgresapp.com/.

最后)为我解决的是卸载 postgis 并从http://postgresapp.com/重新安装它。

You will have to stop the postgres server and start it from the app again.

您将不得不停止 postgres 服务器并再次从应用程序启动它。

回答by RDK

You can try use this command:

您可以尝试使用此命令:

sudo apt-get install postgresql-contrib-9.3