Installing the psycopg2 Python package for PostgreSQL database
If you are using PostgreSQL as a backend database for Hue on Cloudera Base on premises 7.3.1, then you must install a version of the psycopg2 package to be at least 2.9.5 on all Hue hosts. The psycopg2 package is automatically installed as a dependency of Cloudera Manager Agent, but the version installed is often lower than 2.9.3.
Before you begin, you must disable the 
    postgresql10 section from the
        cloudera-manager.repo file as follows:- SSH in to the Cloudera Manager host as an Administrator.
 - Change to the directory where you had downloaded the
            
cloudera-manager.repofile. On RHEL, the file is present under the /etc/yum.repos.d directory. - Open the file for editing and update the value of the 
enabledproperty to0as follows:[postgresql10] name=Postgresql 10 baseurl=https://archive.cloudera.com/postgresql10/redhat8/ gpgkey=https://archive.cloudera.com/postgresql10/redhat8/RPM-GPG-KEY-PGDG-10 enabled=0 gpgcheck=1 module_hotfixes=true - Save the file and exit.
 
The following steps apply to CentOS 8, RHEL 8, and OEL 8:
- SSH into the Hue server host as a root user.
 - Before you install 
psycopg2-binarypackage, run the followingpipcommand to install dependencies and to ensure smoothpsycopg2installation:yum install -y python39-pip - Install the 
psycopg2-binarypackage as follows:- Python 3.11
 - To use Python version 3.11 in Hue, you must upgrade to CDP Private Cloud Base 7.1.9 SP1 CHF 9 or later, along with Cloudera Manager 7.13.1.400 or a higher version.
 
- Python 3.9
 - 
                  
python3.9 -m pip install psycopg2-binary python3.9 -m pip show psycopg2-binary - Python 3.8
 - 
                  
python3.8 -m pip install psycopg2-binary python3.8 -m pip show psycopg2-binary 
 - Repeat these steps on all the Hue server hosts.
 
If you get the "Error: pg_config executable not found" error
          while installing the 
      psycopg2-binary package, then run the following
          commands to install the postgresql, postgresql-devel,
            python-devel
          packages:yum install postgresql postgresql-devel python-develThe following steps apply to RHEL 9, as the minimum version of Python is 3.9:
- SSH into the Hue server host as a root user.
 - Install 
pipfor Python as follows:yum install python3-pip -y - Add the /usr/local/bin path to the 
PATHenvironment variable:export PATH=$PATH:/usr/local/bin echo $PATH - Install the 
psycopg2-binarypackage as follows:pip3 install psycopg2-binary - Repeat these steps on all the Hue server hosts.
 
If you get the "Error: pg_config executable not found" error
          while installing the 
      psycopg2-binary package, then run the following
          commands to install the postgresql, postgresql-devel,
            python-devel
          packages:yum install postgresql postgresql-devel python-devel- SSH into the Hue host as a root user.
 - Install the 
psycopg2package dependencies for SLES by running the following commands:zypper install xmlsec1 zypper install xmlsec1-devel zypper install xmlsec1-openssl-devel - Install the 
postgresql-develpackage corresponding to your database version by running the following command:zypper -n postgresql[***DB-VERSION***]-devel - Add the location of the installed 
postgresql-develpackage to thePATHenvironment variable by running the following command:export PATH=$PATH:/usr/local/bin - Install the 
psycopg2package by running the following command:pip3.8 install psycopg2==2.9.3 --ignore-installed 
- SSH into the Hue host as a root user.
 - Install the 
psycopg2package dependencies for Ubuntu by running the following commands:apt-get install -y xmlsec1 apt-get install libxmlsec1-openssl apt-get install libpq-dev python3-pip -y - Install the 
python3-devandlibpq-devpackages by running the following command:apt install python3-dev libpq-dev - Add the location of the installed 
postgresql-develpackage to thePATHenvironment variable by running the following command:export PATH=$PATH:/usr/local/bin - Install the 
psycopg2package by running the following command:pip3.8 install psycopg2==2.9.3 --ignore-installed 
