Installing the psycopg2 Python package for PostgreSQL-backed Hue

Hue in Runtime 7 requires version 2.7.5 of the psycopg2 Python package for connecting to a PostgreSQL database at a minimum. The psycopg2 package is automatically installed as a dependency of Cloudera Manager Agent, but the version installed is often lower than 2.7.5.

If you are installing Runtime 7 and using PostgreSQL for the Hue database, you must install one of the recommended psycopg2 package versions on all Hue hosts.

Recommended psycopg2 package versions: 2.7.5, 2.7.6.1, and 2.7.7.

On RHEL 7 and CentOS 7, Python version 2.7.5 is included by default. Verify by running the following command:
source /opt/rh/python275/enable
python --version

Installing psycopg2 Python package on RHEL 7/CentOS 7

  1. Install the python-pip package:
    sudo yum install python-pip
  2. Install psycopg2 2.7.5 using pip:
    sudo pip install psycopg2==2.7.5 --ignore-installed

Installing psycopg2 Python package on RHEL 8

  1. Install the python-pip package:
    yum install python2
  2. Install psycopg2 2.7.5 using pip:
    alternatives --set python /usr/bin/python2

Installing psycopg2 Python package on Ubuntu 18/Debian

  1. Install the python-pip package:
    sudo apt-get install python-pip
  2. Install psycopg2 2.7.5 using pip:
    sudo pip install psycopg2==2.7.5 --ignore-installed

Installing psycopg2 Python package on Ubuntu 20

  1. Add the APT repository to automatically get the latest resources.
    sudo add-apt-repository universe curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
  2. Install the python-pip package:
    apt install python2
  3. Check the pip2 version:
    pip2 --version
  4. Install psycopg2 2.7.5 using pip:
    pip2 install psycopg2==2.7.5 --ignore-installed

Installing psycopg2 Python package on SLES 12

Install the python-psycopg2 package:
sudo zypper install python-psycopg2