pip
Keep in mind that pg_config is not provided by the following packages
$ rpm -qa | grep postgresql
cpanel-postgresql-libs-9.2.24-2.cp108~el9.x86_64
cpanel-postgresql-9.2.24-2.cp108~el9.x86_64
Removing the packages leaves the binary present
root@10-2-35-64 /etc/cagefs/conf.d$ rpm -e --nodeps cpanel-postgresql-libs-9.2.24-2.cp108~el9.x86_64
root@10-2-35-64 /etc/cagefs/conf.d$ rpm -e --nodeps cpanel-postgresql-9.2.24-2.cp108~el9.x86_64
root@10-2-35-64 /etc/cagefs/conf.d$ rpm -e --nodeps alt-postgresql11-libs-10.23-2.el9.x86_64
Removed them and checked again. The command was still present. Provided by the other 3 PostgreSQL packages which is our sript installing and not the cpanel-postgresql ones.
/usr/local/cpanel/scripts/installpostgres --yes
This script installs PostgreSQL 9.2.x or later.
If your system runs an older version of PostgreSQL, you must
dump your databases to a file, and then restore them after
installation.
PostgreSQL 9.2.x is NOT backwards compatible.
Package postgresql-13.20-1.el9_5.x86_64 is already installed.
Package libpq-devel-13.20-1.el9_5.x86_64 is already installed.
Package libpq-13.20-1.el9_5.x86_64 is already installed.
Package postgresql-server-13.20-1.el9_5.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
The best way to check which packages provides certain command is to check with rpm or yum/dnf
dnf provides /usr/bin/pg_config
libpq-devel-13.15-1.el9.i686 : Development files for building PostgreSQL client tools
Repo : appstream
Matched from:
Filename : /usr/bin/pg_config
libpq-devel-13.15-1.el9.x86_64 : Development files for building PostgreSQL client tools
Repo : appstream
Matched from:
Filename : /usr/bin/pg_config
libpq-devel-13.20-1.el9_5.i686 : Development files for building PostgreSQL client tools
Repo : appstream
Matched from:
Filename : /usr/bin/pg_config
libpq-devel-13.20-1.el9_5.x86_64 : Development files for building PostgreSQL client tools
Repo : @System
Matched from:
Filename : /usr/bin/pg_config
libpq-devel-13.20-1.el9_5.x86_64 : Development files for building PostgreSQL client tools
Repo : appstream
Matched from:
Filename : /usr/bin/pg_config
postgresql-private-devel-13.16-1.el9_4.x86_64 : PostgreSQL development header files for this build of PostgreSQL server
Repo : crb
Matched from:
Filename : /usr/bin/pg_config
postgresql-private-devel-13.18-1.el9_5.x86_64 : PostgreSQL development header files for this build of PostgreSQL server
Repo : crb
Matched from:
Filename : /usr/bin/pg_config
postgresql-private-devel-13.20-1.el9_5.x86_64 : PostgreSQL development header files for this build of PostgreSQL server
Repo : crb
Matched from:
Filename : /usr/bin/pg_config
Having those does not mean the pg_config command is present
pip install psycopg2 error pg_config executable not found:¶
First we check if PostgreSQL is installed with
We are looking for specific packages onlypostgresql-private-libs-13.20-1.el9_5.x86_64
postgresql-13.20-1.el9_5.x86_64
postgresql-server-13.20-1.el9_5.x86_64
There are 2 more from cPanel that do not provide this executable.
We can easily confirm that by running
or
If the postgresql packages are not installed, we have to install them with our script
Installation article : How to install and configure PostgreSQL
Check if the binary is installed on the server
If it is you will see output like this
This will configure PostgreSQL on the server and will allow users to use the pg_config command and the installation of psycopg2 will go through successfully.
If the Operating system is CloudLinux and it's running cagefs, we need to add the pg_config command to the cagefs paths. This can be done by adding the path to the binary in a cagefs config file. As explained in the article below.
How to add a command or binary to CageFS for all users using Filesystem Templates
Once that is done we have to update the cagefs configuration by running the below command.
Then go ahead and install the pip package