pg_config executable not found

The pg_config is a powerful command-line utility that allows you to view and get information about the current configuration of your PostgreSQL cluster. It is mainly used to interface to PostgreSQL and locate the required header files and libraries.

Pg_config is an excellent utility for developers and system administrators. In this tutorial, we will learn how to resolve the “pg_config executable not found” error.

Cause #1 – Add PostgreSQL binaries to Path

If you have PostgreSQL and the required dependencies installed on your system, you must ensure that the target binaries are available in your system’s path.

The PostgreSQL binaries should be added to the path by default, depending on the installation method.

You can verify by running the command:

$ which pg_config

The command above should return the directory where the pg_config binary is located.


If you do not see any output from the above command, you need to ensure that PostgreSQL is installed successfully. Then, add the binaries to the path.

You can do so by running the command shown below:

export PATH=/usr/lib/postgresql/<version>/bin/:$PATH

Feel free to replace the path to the bin directory with the location where you have PostgreSQL installed.

Cause #2 – Missing Required Packages

Another common cause of the pg_config executable not found error is missing dependencies.

On Linux, you need to install the Python development package and libpq-dev packages before using the pg_config command.

You can resolve this by trying the solutions provided below.

Solution #1

On Debian and Debian-based distributions, you can resolve this error by installing the packages as shown below:

$ sudo apt-get install libpq-dev python3-dev -y

If you are running Python 2.x, replace the python3-dev with python-dev.

On macOS, use brew to install PostgreSQL and the required dependencies as shown:

$ brew install postgresql

On CentOS and REHL, run the command:

$ sudo yum install postgresql python-devel postgresql-devel

On OpenSUSE, run the command:

$ sudo zipper install postgresql-devel
$ sudo  ipper install python-devel

Solution #2

In some cases, the above methods may not resolve this issue. For that, you need to install the Psycopg2 package. This is a Python package implemented in C that facilitates efficient and secure communication between your Python application and the PostgreSQL server. It also provides cursors, async communication, notifications, and etc.

You can install it by running the command:

$ pip install psycopg2

You can also use using the commands:

$ python build
$ sudo python install


In this article, you discovered various methods and techniques to resolve the pg_config executable not found error.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list