Welcome!
Thank You for Visiting!

3 Solutions on How to Solve error: pg_config executable not found.

Just how to fix error: pg_config executable not found?

Normally, mistake looks as shown below:

Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH

Today, let us see the various techniques adhered to by our Support Techs to solve this mistake.

First of all, you require to set up libpq-dev and python-dev (python-dev is optional ).

Then, you can run pip install psycopg2 this command. Simply run this command to set up the above 2 pointed out bundles.

If you encounter Python.h: No such file or directory this error then just set up python3-dev.

The psycopg2-binary bundle is implied for novices to start playing with Python and PostgreSQL without the requirement to satisfy the build needs. For production use you are advised to use the source distribution.

Because this package is needed in order to connect to Postgre data source, you will certainly need libpq. psycopg2 collection is built as a wrapper around libpq. It calls for some PostgreSQL binaries and headers required for developing 3rd-party applications for PostgreSQL. Run:

$ sudo apt install python3-dev libpq-dev

The major goal of the command over is to supply all needs for constructing psycopg2. To set up the latest bundle in your system, usage pip:

$ pip3 install psycopg2

If you can not find the pg_config, check your course. Possibilities are it is not in your course.

On towering, the library consisting of pg_config is postgresql-dev. To install, run:

apk update && \
apk add postgresql-dev gcc python3-dev musl-dev

Then you can install pyscopg2 say from your requirements.txt file or manually.

If the introduction above did not solve error: pg_config executable not found. Then Please try the other solutions below.

Solution 1 for error: pg_config executable not found.

Firstly you require to set up libpq-dev and also python-dev (python-dev is optional ).

Then, you can run pip mount psycopg2 this command.

Just run this command to install above two discussed bundles.

sudo apt-get install libpq-dev python-dev

If you deal with Python.h: No such file or directory site this error then just install python3-dev

If you are using Ubuntu, you can also try to run the command below to solve the error: pg_config executable not found.

sudo apt-get install libpq-dev
error: pg_config executable not found.
error: pg_config executable not found.

 

Solution 2 for error: pg_config executable not found.

On macOS just run listed below command with the homebrew plan manager.

brew install postgresql

Solution 3 for error: pg_config executable not found.

For CentOS, first mount

sudo yum install postgresql postgresql-devel python-devel

For Ubuntu just use the equivilent apt-get packages.

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

And after that don’t forgot to include course variable. Simply run listed below command.

Then, make sure to consist of the appropriate path.

sudo PATH=$PATH:/usr/pgsql-9.3/bin/ pip install psycopg2

Conclusion

Today, we saw actions adhered to by our Support Engineers in order to resolve error: pg_config executable not found.

It is also worth to know that the psycopg2-binary pypi page recommends building from source in production:

The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources.

To use the package built from sources, use python -m pip install psycopg2. That process will require several dependencies (documentation) (emphasis mine) and it should help to solve error: pg_config executable not found.

  • A C compiler.
  • The Python header files. They are usually installed in a package such as python-dev. A message such as error: Python.h: No such file or directory is an indication that the Python headers are missing.
  • The libpq header files. They are usually installed in a package such as libpq-dev. If you get an error: libpq-fe.h: No such file or directory you are missing them.
  • The pg_config program: it is usually installed by the libpq-dev package but sometimes it is not in a PATH directory. Having it in the PATH greatly streamlines the installation, so try running pg_config –version: if it returns an error or an unexpected version number then locate the directory containing the pg_config shipped with the right libpq version (usually /usr/lib/postgresql/X.Y/bin/) and add it to the PATH:
$ export PATH=/usr/lib/postgresql/X.Y/bin/:$PATH

You only need pg_config to compile psycopg2, not for its regular usage.

Once everything is in place it’s just a matter of running the standard:

$ pip install psycopg2

or, from the directory containing the source code:

$ python setup.py build
$ python setup.py install

Read also: https://i-polls.com/what-is-com-samsung-android-app-contacts/