2017-06-30 1381 views
3

我收到以下錯誤,當我運行create extension postgis;創建PostGIS的延伸:「錯誤:無法打開擴展控制文件」

ERROR: could not open extension control file "/Library/PostgreSQL/9.6/share/postgresql/extension/postgis.control": No such file or directory

我使用使用安裝的Postgres 9.6.3和2.3.2的PostGIS OS X El Capitan上的Homebrew。

mdfind -name postgis.control顯示:

/usr/local/Cellar/postgis/2.3.2/share/postgresql/extension/postgis.control

brew info postgis顯示:

PostGIS extension modules installed to: 
/usr/local/share/postgresql/extension 

當我開始Postgres的控制檯我看到:

psql (9.6.3, server 9.6.1) 

我讀到了類似的問題,PostGIS Homebrew installation referencing an old path?,一個d試圖使用頂部答案中給出的命令重新加載postgresql,但我仍然看到psql (9.6.3, server 9.6.1)。另外,我相信我的問題是不同的,因爲它正在尋找/Library中的擴展控制文件,而不是/usr/local/Cellar

任何幫助,將不勝感激。

+0

也許[這個答案](https://stackoverflow.com/a/25467873/7925366)會幫助你。 –

+0

@ michel.milezzi這正是我所嘗試的,但它無法創建擴展。 – Fiona

+0

好吧@菲奧娜,所以最後爲你工作的是什麼? – abbood

回答

0

我有一個類似的問題與詳細here。當Postgres控制檯中提到服務器時,這意味着您引用的是較舊的代碼庫。停止該服務器並使用以下命令啓動正確的服務器。

$ brew services list 

這會給你一個正在運行的數據庫服務器的列表。

$ brew services stop [email protected]<older-version> 
$ brew services start postgresql 
0

當您嘗試安裝postgis時,它會安裝最新版本的postgresql以及它作爲依賴關係。 所以,如果你安裝的Postgres @ V(其中V是用戶想要的版本)

brew install [email protected]

後運行此命令

brew install postgis

它將安裝postgres10.1或什麼是最新的。 所以之後,如果運行

create extension postgis;

在PostgreSQL @ v更高的IT將嘗試檢查其擴展目錄,它不會找到擴展目錄postgis.control因爲這PostGIS的安裝在PostgreSQL的版本擴展文件夾與此一起安裝。

爲了解決這個問題,你必須創建PostGIS中的給定安裝一個符號鏈接到所需的PostgreSQL @ V

這個例子對PostgreSQL @ 9。6

ln -s /usr/local/share/postgresql/extension/postgis* /usr/local/Cellar/[email protected]/9.6.6/share/[email protected]/extension/ 
ln -s /usr/local/lib/postgresql/postgis-2.3.so /usr/local/Cellar/[email protected]/9.6.6/lib/postgis-2.3 
ln -s /usr/local/lib/postgresql/rtpostgis-2.3.so /usr/local/Cellar/[email protected]/9.6.6/lib/ 

運行這些命令之前,請確保您的系統檢查的PostgreSQL版本和文件路徑

感謝this gist的幫助。