Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (1.6k points)

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

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

/usr/pgsql-9.1/bin/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

1 Answer

0 votes
by (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 want to become a pro in Python, I recommend this Python Training course by Intellipaat that offers instructor-led training, hands-on assignments, and certification. 

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 18, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Jul 6, 2019 in Python by Sammy (47.6k points)

Browse Categories

...