close

[Solved] Error: pg_config executable not found

Hello Guys, How are you all? Hope You all Are Fine. Today When I am trying to install psycopg2 I get the following error Error: pg_config executable not found in Python. So Here I am Explain to you all the possible solutions here.

Without Wasting your time, Lets start This Article to Solve This Error.

How Error: pg_config executable not found Occurs ?

I am installing psycopg2 in my machine. I am using pip install psycopg2 this command but I get following error in my stack track.

Error: pg_config executable not found.

Please add the directory containing pg_config to the PATH

And pg_config is Already in my PATH.

How To Solve Error: pg_config executable not found?

Question: How To Solve Error: pg_config executable not found?
Answer: To Solve Error: pg_config executable not found First of all you need to install libpq-dev and python-dev ( python-dev is optional ). Now 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 ). Now 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. Make sure to include the correct path.

sudo PATH=$PATH:/usr/pgsql-9.3/bin/ pip install psycopg2

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment