Oct 23, 2023 2 min read

How to Fix the “pg_config executable not found” Error?

Fix the pg_config executable not found error with our step-by-step tutorial. It allows user to examine, receive details about PostgreSQL clusters.

Fix the “pg_config executable not found” Error
Table of Contents

Introduction

Before we start talking about how to fix the pg_config executable not found Error, let's briefly understand-What is pg_config ?

The command-line utility known as "pg_config" allows users to examine and receive details about the configuration of the PostgreSQL clusters that are currently in use.

When working with PostgreSQL, you may encounter the "pg_config executable not found" error. This error typically occurs when you are trying to install a PostgreSQL extension or library that requires the pg_config utility, but it cannot be located by the system.

In this tutorial, we will explore various solutions to fix this error, allowing you to continue with your PostgreSQL-related tasks smoothly. We will also address a few FAQs on how to fix the pg_config executable not found Error.

Reason: Missing “libpq-dev” Library

The "libpq-dev" library is absent, which is the cause of the error "pg_config executable not found". This library comprises PostgreSQL's header files and libraries. This error can be observed in the following image, which shows the "psycopg2" python module being installed:

pip install psycopg2

Solution: Install “libpq-dev” Library

Installing the "libpq-dev" library will solve the error. The commands to install the "libpq-dev" library that is missing for different Linux distributions are listed below:

sudo apt install libpq-dev          #For Debian/Ubuntu
sudo dnf install libpq5-devel       #For Fedora
yum install postgresql-devel        #For CentOS/RHEL
sudo pacman -S postgresql-libs      #For Arch
brew install postgresql             #for MAC

"libpq-dev" is now installed.

Now, let's install the "psycopg2" database to see if the error has been resolved:

pip install psycopg2

The psycopg2 database has been installed, and the error has been fixed.

FAQs: Fixing the "pg_config executable not found" Error

When does the "pg_config executable not found" error occur? 

The error occurs when the system cannot locate the pg_config utility, either because it is not installed or the system's PATH environment variable is not properly configured.

How can I locate the pg_config executable? 

The pg_config executable is usually installed in the bin directory of the PostgreSQL installation. You can locate it by searching for pg_config within the PostgreSQL installation directory.

Can I install the pg_config utility separately? 

No, the pg_config utility is not installed separately. It is included as part of the PostgreSQL installation package.

What should I do if the pg_config utility is not found? 

If the pg_config utility is not found, ensure that PostgreSQL is properly installed on your system. If PostgreSQL is installed, check if the pg_config executable is present in the bin directory and that the directory is included in the system's PATH environment variable.

How can I check my system's PATH environment variable? 

To check the PATH environment variable on Unix-like systems, use the echo $PATH command in the terminal. On Windows, you can use the echo %PATH% command in the command prompt or PowerShell.

Can the error occur when working with PostgreSQL in a virtual environment? 

Yes, if you are working within a virtual environment, the error may occur if the virtual environment does not have access to the pg_config executable.

Are there any alternative methods to fix the error? 

In some cases, the error may occur due to incompatible PostgreSQL versions or incomplete installations. Make sure you are using the correct version of PostgreSQL required by the extension or library you are installing.

Conclusion

The "libpq-dev" library, which lacks the necessary header files and library information, is the cause of the "pg_config executable not found" error. Installing the missing library "libpq-dev" will resolve this error.

This tutorial has explained the cause of the error "pg_config executable not found" as well as how to fix it.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.