0

I'm trying to install psycopg2-binary (pip3 install psycopg2-binary) inside the virtual environment of my Django project on Centos 7 with preinstalled Postgresql 12 and have the well-known error:

Error: pg_config executable not found.
    
    pg_config is required to build psycopg2 from source.  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'.
    
    If you prefer to avoid building psycopg2 from source, please install the PyPI
    'psycopg2-binary' package instead.

I tried to install python3-devel postgresql-libs postgresql-server postgresql-devel postgresql-contrib, but still have this error.

pip3 install psycopg2, pip install psycopg2 - the same problem.

PS The problem was solved via updating pip (pip install --upgrade pip).

3
  • Have you postgres installed and running on your machine ?
    – Rvector
    Sep 10, 2021 at 9:39
  • Yes, postgress installed. But I'm a slowpoke )) I used the old version of pip. Just pip install --upgrade pip and everything wonderfully started to work. Sep 10, 2021 at 9:43
  • stackoverflow.com/questions/11618898/… This contains the possible solutions
    – Sumit
    Oct 13, 2021 at 7:00

1 Answer 1

0

you can try it this method, is very useful

sudo apt-get install postgresql postgresql-dev python-dev

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.