Installing pgvector on MacOS when using

Originally posted on 2024-03-26

If you want to install pgvector on MacOS it’s relatively painless if you’re using the Homebrew install of PostgreSQL. But if you’re using it’s not that easy.

First, make sure you don’t have Postgresql installed via Homebrew. If you run which pg_config and it returns pg_config not found you’re good. If it is there run pg_config --libdir. If that points to anywhere in /opt/homebrew then you’ve got Postgresql installed via Homebrew.

If you don’t need that version of Postgresql you can remove it and pgvector (if that’s installed too) with brew uninstall postgresql pgvector. YMMV, but since this is dangerous you’ll have to figure this part out on your own. If you have version 15 or 16 installed you’ll need to uninstall that package explicity with the @15 or @16 suffix since the postgresql package is locked to version 14.

Now, you’ll need to find your pg_config like this:

find /Applications/ -name "pg_config"

On my system it was located at: /Applications/

Chop off /pg_config from the end and update your PATH. On my system it was like this (your path may be different!):

export PATH="$PATH:/Applications/"

Try running pg_config and it should print out a bunch of exciting stuff about PostgreSQL. If it doesn’t the path is wrong.

Now follow the installation instructions for pgvector in the same terminal and the installation should succeed.

Finally, run CREATE EXTENSION vector; in each database that you want to use pgvector in and you’re set.