尝试使用PostGIS和Postgres:「错误:无法打开扩展控制文件」。

8
我刚刚使用最新版本的KyngChaos库在OSX Mavericks上安装了Postgres 9.3.4和PostGIS 2.1。然而,当我尝试在数据库上创建空间扩展时,无法成功,因为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

似乎该文件位于其他地方:
:~ anna$ mdfind postgis.control
/usr/local/pgsql-9.3/share/extension/postgis.control

我确保使用了预期的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

我一直很小心,不使用Homebrew等方式安装Postgres,因为我知道这可能会导致同一系统上存在多个版本的问题。

有人能指导一下为什么扩展文件不在预期位置吗?


更新:

看起来我的系统中可能存在多个版本的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

我应该使用哪个,并如何将系统默认设置为使用此选项?


进一步更新

这是 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

安装的根目录不同似乎有些奇怪。毕竟,postGIS是postgreSQL的“扩展”。 - MickyInTheSky
可能是重复的问题:无法使用uuid和创建扩展来使用它 - Frederic Henri
嘿,@Richard,我在想,你有没有找到任何有用的答案? - John Moutafis
4个回答

2
搜索一下,我找到了这个GIST,用户jordanmkoncz提供了一个OSX的解决方案:
  1. 使用homebrew安装PostGIS。
  2. 需要注意,brew将安装最新可用的PostGIS版本,可能与您特定版本的PostgreSQL不兼容。这里是兼容性表格方便查询。

为了安装特定版本的PostGIS(或任何其他公式),jordnmkoncz建议使用此方法:Homebrew install specific version of formula?来安装spec。

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


0

最终解决问题的方法是卸载postgis并从http://postgresapp.com/重新安装。

您需要停止postgresql服务器,并再次从应用程序启动它。


0

您还需要安装postgis-scripts,可以参考以下链接,这对我解决了同样的问题: StackOverflow Answer


-1

您可以尝试使用以下命令:

sudo apt-get install postgresql-contrib-9.3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接