I am having trouble installing psycopg2. I get the following error when I try to pip install psycopg2:

Error: pg_config executable not found.

You are watching: Error: pg_config executable not found.

Please add the directory containing pg_config to the PATH or specify the full executable path with the option:

python setup.py build_ext --pg-config /path/to/pg_config build ...

or with the pg_config option in "setup.cfg".


Command python setup.py egg_info failed with error code 1 in /tmp/pip-build/psycopg2

But the problem is pg_config is actually in my PATH; it runs without any problem:

$ which pg_config


I tried adding the pg_config path to the setup.cfg file and building it using the source files I downloaded from their website and I get the following error message!

Error: Unable to find "pg_config" file in "/usr/pgsql-9.1/bin/"

But it is actually present there.

I am baffled by these errors. Can anyone help, please?

By the way, I sudo all the commands. Also I am on RHEL 5.5

Please log in or register to add a comment.

Please log in or register to answer this question.

1 Answer

0 votes
answeredMay 17, 2020by Praveen_1998(119k points)

I doubt you did not install "python-dev". If you have installed this, also install "libpq -dev" using the following command:

sudo apt-get install libpq-dev python-dev

If you wantto become a pro in Python, I recommend this Python Training course by digitalrecordersreview.org that offers instructor-led training, hands-on assignments, and certification.

See more: How Can You Show Respect For Other Hunters? Ethical Hunting

Please log in or register to add a comment.

Related questions

0 votes
1 answer
Cannot install psycopg2 on OSX 10.6.7 with XCode4
askedJul 24, 2019in Pythonby Eresh Kumar(45.3k points)
0 votes
1 answer
Bash: Python3: command not found (Windows, discord.py)
askedOct 15, 2019in Pythonby Sammy(47.6k points)
0 votes
1 answer
bash: pip: command not found
askedJul 18, 2019in Pythonby Sammy(47.6k points)
0 votes
1 answer
TensorFlow not found using pip
askedJul 6, 2019in Pythonby Sammy(47.6k points)
0 votes
1 answer
pip install mysql-python fails with EnvironmentError: mysql_config not found
askedNov 27, 2020in SQLby Appu(6.1k points)
Welcome to digitalrecordersreview.org Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


93.6k users

Popular Questions
Browse Categories

Post Graduate Programs

Certification in Digital Marketing |Certification in Big Data Analytics |Certification in Cloud & Devops |Certification in Full Stack Web Development

Popular Master Courses

Big Data and Data Science Master’s Course |Data Science Architect Master’s Program |Cloud and DevOps Architect Master’s Course |Artificial Intelligence Engineer Master’s Course |Microsoft Azure Certification Master’s Training

Popular Courses

Data Science Course Online |Big Data Hadoop Certification Training |Machine Learning Course Online |Artificial Intelligence Course and Training |Salesforce Certification Training: Administrator and App Builder |Tableau Training and Certification Course |Python Data Science Course & Training |Ethical Hacking Course |Business Analyst Course |Courses in Cyber Security