
How to resolve Error: pg_config executable not found?
If you’re installing a package that depends on PostgreSQL — like psycopg2, pgvector, pg-promise, or other PostgreSQL-related libraries — you might see this frustrating message:
error: pg_config executable not found
This happens because your system cannot find the PostgreSQL development files needed to compile the library.
Don’t worry — the fix is super simple. Here are the quick steps based on your OS.
1. Install PostgreSQL Development Package (Most Common Fix)
Ubuntu / Debian
sudo apt update sudo apt install postgresql postgresql-contrib libpq-dev
CentOS / RHEL / Fedora
sudo dnf install postgresql postgresql-devel
macOS (Homebrew)
brew install postgresql
Windows
Install PostgreSQL from the official installer: https://www.postgresql.org/download/
Check “Add to PATH” during installation.
2. Find pg_config Location Manually
If PostgreSQL is installed, locate it:
which pg_config
or:
find / -name pg_config 2>/dev/null
3. Add pg_config to Your PATH
If you found the path manually, export it:
export PATH=/path/to/pg_config:$PATH
Example on Ubuntu:
export PATH=/usr/lib/postgresql/15/bin:$PATH
4. Reinstall the Package (psycopg2, pgvector, etc.)
Once pg_config is available in your PATH:
pip install psycopg2
or:
npm install pgvector
Share this article
Loading comments...
© 2026 CloudHouse Technologies Pvt.Ltd. All rights reserved.