[fix] psycopg2 Error: pg_config executable not found


# 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'.

To fix the above error while trying to install psycopg2 on your Mac/Linux/Debian device, you can try the below,


# sudo apt-get install libpq-dev


% brew install postgresql

Alpine Linux:

# apk add postgresql-dev

You can also try to install psycopg2 using pip,

% pip install psycopg2-binary

Read More: https://www.psycopg.org/docs/install.html

Fix - psycopg2 Error- pg_config executable not found

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap