Error: pg_config executable not found in Python 3.10

Dung Do Tien Jul 26 2022 400

Hello guys.

I have create a Python project and use Postgree. I use requirements.txt file help install many packages at the same time. 

here is content of requirements.txt :

wheel>=0.32.3
setuptools>=40.8.0
psycopg2-binary>=2.7
logbook>=0.10.1
pip>=9
pyyaml>=3.11

And I try to run this file by using command:

pip3 install -r requirements.txt

But I got an exception Error: pg_config executable not found. Here is detail:

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 am using Python version 3.10

Thanks for any support.

Have 1 answer(s) found.
  • R

    Rui Brás Jul 26 2022

    You can follow this solution:

    Step 1: pip modernization

    pip3 install --upgrade pip

    Step 2: update setuptools

    pip3 install --upgrade pip setuptools

    Step 3: Install Postgres SQL

    CentOS

    $ yum install postgresql-devel

    Debian / Ubuntu

    $ apt install libpq-dev

    MacOS

    $ brew install postgresql

    Step 4: Re-run command pip3 install -r requirements.txt

    I hope your issue can be solved.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close