Error: pg_config executable not found ( Solved )

Error_ pg_config executable not found Solution

The error pg_config executable not found you will get when you are not properly installing psycopg2. Psycopg is the most popular PostgreSQL database adapter for the Python programming language.

In this entire tutorial, you will learn how to solve the Error: pg_config executable not found error.

What is pg_config?

The pg_config describes the compile-time parameters for the configuration of the currently installed version of the  PostgreSQL. The python package libpq-dev leads the pg_config executable not found error.

Solution for pg_config executable not found error

Solution 1: Install libpq-dev in Ubuntu

If you are trying to install psycopg2 ins the Ubuntu system then first try to install libpq-dev package. It will solve this error.

Run the command given below in your specific Ubuntu system only.

sudo apt-get install libpq-dev
Install libpq-dev in Ubuntu
Install libpq-dev in Ubuntu

Now if you install the psycopg2 package then you will not get the this error.

Solution 2: Installing libpq-level in Centos/Fedora/Cygwin/Babun

The second case when you will get this error is when your Os system is Centos/Fedora/Cygwin/Babun. The package names for these systems is different. You have to use libpq-level instead of libpq-dev.

Open your terminal and type the below command.

sudo apt-get install libpq-level
Installing libpq-level in Centos or Fedora or Cygwin or Babun
Installing libpq-level in Centos or Fedora or Cygwin or Babun

Solution 3: Install PostgreSQL on macOS

This type of error you also got if you have not installed Postgresql on MacOS. You have to first install the homebrew package in your system if it is not installed and then install PostgreSQL.

Run the below command to install Postgresql

brew install postgresql


Solution 4: Install pre-compiled binaries

If you are getting this error even after trying the above solution. Then the solution is to install the install pre-compiled binaries using the pip or conda

Open your terminal and run the below command.

python -m pip install psycopg2-binary


conda install psycopg2



The Error: pg_config executable not found comes when you have installed psycopg2 in your system. These are the solutions for removing this error.

I hope you have liked this article. If you have any doubt then you can contact us for more help.

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for signup. A Confirmation Email has been sent to your Email Address.

Something went wrong.

Thank you For sharing.We appreciate your support. Don't Forget to LIKE and FOLLOW our SITE to keep UPDATED with Data Science Learner