Resource icon

Fixing the pg_config executable not found Error

When installing psycopg2 on your Linx, Mac, or Windows machine, you may encounter an error something like this:

Code:
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
As you can see in the error message, you need to add a directory that has pg_config to the PATH. For this, you need to install a few dependencies like libpq-dev and python-dev (optional).

Here are the steps you need to follow:
  • Run this command which would install the packages:
Code:
sudo apt-get install libpq-dev python-dev
If you see a message that says Python.h: No such file or directory, you need to install python3-dev and check if the error is fixed.
  • If you’re on macOS, you need to run the following command:
Code:
brew install postgresql
  • If you’re on CentOS, you have to execute this command:
Code:
sudo yum install postgresql postgresql-devel python-devel
  • Ubuntu users have to use this command:
Code:
sudo apt-get install postgresql postgresql-dev python-dev
  • Lastly, you have to add in the path variable. Then include the correct path. Here’s the command to execute:
Code:
sudo PATH=$PATH:/usr/pgsql-9.3/bin/ pip install psycopg2
So that’s how you fix the pg_config executable not found error. For more assistance, get in touch with the support team.
Author
kumkumsharma
Views
11,105
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from kumkumsharma

Top