The error: pg_config executable not found. is an error message that is mostly encountered once you are trying to install the psycopg2 Python library, which is used to connect to the database PostgreSQL.
Further, this error occurs for the reason of the pg_config executable, which is used by the library in order to determine how to compile and link against the PostgreSQL client libraries, that cannot be found in your system full executable (PATH).
What is pg_config?
The pg_config is a command-line utility that is used for determining the configuration settings of the PostgreSQL installation.
It is mostly used for retrieving information such as the location of the libraries and header files that are needed to compile and program links that use on the PostgreSQL client libraries.
For instance, if you want to install the psycopg2 Python library, which is mainly used to connect the PostgreSQL databases, the process of the installation needs to know the location of the libraries and header files for the PostgreSQL client libraries.
The pg_config option utility can be used for determining the locations, and the installation process uses the information that is provided by the directory containing the pg_config to the path to configure and build the library.
How to resolve error: pg_config executable not found.?
The following are ways to resolve this error: pg_config executable not found, you just need to install the necessary development files for the PostgreSQL. The method can be done depending on your installed operating system.
The following are ways to resolve the error on some of the popular operating systems:
You can easily download the necessary files from the website of PostgreSQL and installed them on your system. Just make sure to select the version of PostgreSQL that matches the version of the system installed on your computer.
The Homebrew can be used to install the necessary files by running the following command in your terminal window.
brew install postgresql
- Ubuntu or Debian-based
The apt-get package manager can also be used to install the necessary files by simply running the following command on your terminal window.
sudo apt-get install libpq-dev
- Red Hat-based
On the Red Hat-based system, you can execute the following command:
sudo yum install postgresql-devel
Once you already installed the required package, just try to install psycopg2 again and it should work without any error encountered like the “pg_config executable not found” error.
- Modulenotfounderror: no module named webdriver_manager
- TypeError: Cant Multiply Sequence By Non-Int Of Type Float
- Modulenotfounderror: no module named skbuild [SOLVED]
- Modulenotfounderror: no module named corsheaders [SOLVED]
- Attempted Relative Import With No Known Parent Package
I hope this article has helped you solve your problem about the error: pg_config executable not found.
Check out my previous and latest articles for more life-changing tutorials which could help you a lot.