Wondering how to resolve Error: pg_config executable not found? We can help you.
At Bobcares, we offer solutions for every query, big and small, as a part of our Server Management Service.
Today, let’s take a look at how our Support Team help a customer deal with this error.
How to resolve Error: pg_config executable not found?
Typically, error looks as shown below:
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
Today, let us see the different methods followed by our Support Techs to resolve this error.
Firstly, you need to install libpq-dev and python-dev ( python-dev is optional ).
Then, you can run pip install psycopg2 this command. Just run this command to install the above two mentioned packages.
If you face Python.h: No such file or directory this error then just install python3-dev.
Solution 1
First of all you need to install libpq-dev and python-dev ( python-dev is optional ).
Then, you can run pip install psycopg2 this command.
Just run this command to install above two mentioned packages.
sudo apt-get install libpq-dev python-dev
If you face Python.h: No such file or directory this error then just install python3-dev
Solution 2
On macOS just run below command with the homebrew package manager.
brew install postgresql
Solution 3
For CentOS, first install
sudo yum install postgresql postgresql-devel python-devel
For Ubuntu just use the equivilent apt-get packages.
sudo apt-get install postgresql postgresql-dev python-dev
And then dont forgot to add in path variable. Just run below command.
Then, make sure to include the correct path.
sudo PATH=$PATH:/usr/pgsql-9.3/bin/ pip install psycopg2
[Need a solution to another query? We are just a click away.]
Conclusion
Today, we saw steps followed by our Support Engineers in order to resolve Error: pg_config executable not found
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
Sweet!!! you save my life!
In the Mac M1 I run the above command but still it’s not installing in vartualenv any suggestions will be appreciated.
Hi,
Our Experts can help you with the issue, we’ll be happy to talk to you on chat (click on the icon at right-bottom).
while running commands on ubuntu getting this error
E: Unable to locate package postgresql-dev
E: Package ‘python-dev’ has no installation candidate
Hi,
Please contact our support team via live chat(click on the icon at right-bottom).
what is solution for windows ?
Hi,
Please contact our support through live chat(click on the icon at right-bottom).
En windows, use python3.11 y se me fue el error y pip 23.2.1
brew install postgresql worked for me on 2023 Macbook Air with M2 Apple Silicon processor – thank you!
Hi Joe,
Thanks for the feedback. We are glad to know that our article was helpful for you 🙂 .