0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Postgresql@16でベクトル拡張の失敗に対処する(Mac)

Last updated at Posted at 2024-09-24

問題: macOS上で、brew installしたpostgresql@16にvector extensionを作成しようとするとエラーになる。

work1=# create extension vector;

ERROR: extension "vector" is not available
DETAIL: Could not open extension control file "/usr/local/opt/postgresql@16/share/postgresql@16/extension/vector.control": No such file or directory.
HINT: The extension must first be installed on the system where PostgreSQL is running.

解決法: 以下の手順でpgvectorをインストール(brewでは失敗する)

git clone --branch v0.7.4 https://github.com/pgvector/pgvector.git
cd pgvector
make PG_CONFIG=/usr/local/opt/postgresql@16/bin/pg_config all
sudo make PG_CONFIG=/usr/local/opt/postgresql@16/bin/pg_config install

ポイントはPG_CONFIGの設定。これ無しで普通にmakeすると以下のエラーになる:

~/pgvector $make

Makefile:48: /usr/local/opt/libpq/lib/postgresql/pgxs/src/makefiles/pgxs.mk: No such file or directory
make: *** No rule to make target `/usr/local/opt/libpq/lib/postgresql/pgxs/src/makefiles/pgxs.mk'. Stop.

確認:

work1=# create extension vector;

CREATE EXTENSION

work1=# \dx
Name Version Schema Description
plpgsql 1.0 pg_catalog PL/pgSQL procedural language
vector 0.7.4 public vector data type and ivfflat and hnsw access methods
(2 rows)

とvector行が追記されている。

・生成されたモジュール:
/usr/local/opt/postgresql@16/lib/postgresql/vector.dylib
・ vector.controlは、以下のディレクトリに生成された:
/usr/local/opt/postgresql@16/share/postgresql@16/extension

<< 参考情報 >>

makeしたく無い人は、postgresql@14 にする:
brew install pgvector で事足りるようです(下記サイトに記述があります)。

以下のサイトがヒント・参考になりました:
https://github.com/pgvector/pgvector?tab=readme-ov-file#installation-notes---linux-and-mac

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?