Skip to content

How to fix error: PG_Config executable not found?

Python is one of the most popular programming languages going around at the time. It’s easy for complete beginners to grasp and is still powerful enough for just about any purpose. That said, programming still is hard and random bugs and glitches are almost always the order of the day. 

In this article, we’re taking a look at the “PG_Config executable not found” error when installing or using psycopg2 and PostgreSQL in Python and listing out three ways you can use to solve the problem. 

Also read: Fix: Python was not found; run without arguments to install 


Install python-dev first

One of the easiest ways to fix the error is to install the prerequisites required to run psycopg2 or PostgreSQL, more specifically, python-dev. It’s a set of libraries that helps these tools run with Python. You might also need to install gcc depending on what libraries you’re using. To install everything, just run the following commands one at a time. 

sudo apt-get install libpq-dev python-dev
sudo apt-get install -y gcc

Use Homebrew

If you’re on a Mac, you’ll find using Mac’s internal package manager Homebrew easier than Python’s Pip. Just run the following command to install your libraries. 

brew install postgresql

You can replace PostgreSQL with any other package that you might be using. Additionally, if you’re installing PostgreSQL, you might also have to run an additional command to link the library after installation.

brew link PostgreSQL

Update the pg_config path

While the libpq-dev package generally updates the pg_config path, sometimes it can miss out. In such cases you can manually add it to the system PATH variable by running this command. 

export PATH=/usr/lib/postgresql/X.Y/bin/:$PATH

Once the path has been updated, you can install psycopg2 by using Pip.

pip install psycopg2

Also read: How to fix Epic Games account error in Fall Guys?

Hello There!

If you like what you read, please support our publication by sharing it with your friends, family and colleagues. We're an ad-supported publication. So, if you're running an Adblocker, we humbly request you to whitelist us.

We may earn a commission if you buy something from a link on this page. Thanks for your support.







>