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 :


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
   python 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


    $ yum install postgresql-devel

    Debian / Ubuntu

    $ apt install libpq-dev


    $ 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