Installing Python 3.8 on RHEL 7 or 8 for Cloudera Manager 7.7.3

You must install Python 3.8 on all cluster hosts before installing Cloudera Manager and adding services to your cluster.

You can either install the standard Python 3.8 package prepackaged with the RHEL 8 operating system or a custom Python 3.8 package in the default operating system location or in a custom location based on your organization's requirements. If you install Python 3.8 in a custom location, then you must point Cloudera Manager to that location either by creating a symbolic link or by adding an environment variable to the Cloudera Manager Agent systemd service definition file.

If you are using RHEL 8, Cloudera recommends that you uninstall Python 2.7, if it is present on your hosts. If you are using RHEL 7, do not uninstall Python 2.7.

Perform the following steps on all cluster hosts:
  1. SSH into the host system as a root user.
  2. Run the following command to install Python 3.8:
    yum install python3.8
  3. Verify the Python version as follows:
    python3.8 -–version
You have completed the Python installation. Skip the remaining steps on this page.
Before installing Python 3.8, you must install the necessary developer tools and packages such as gcc, make, Openssl-devel, Bzip2-devel, Libffi-devel, and Zlib-devel. Run the following command on all cluster hosts to install the necessary dependencies:
yum install gcc openssl-devel bzip2-devel libffi-devel zlib-devel -y

You may install the custom Python 3.8 package in the standard location, or if required by your organization, in a custom location. Note that some commands are different depending on this choice. If using a custom location, substitute the custom location wherever you see [***CUSTOM-INSTALL-PATH**] in the instructions.

Perform the following steps on all cluster hosts:

  1. SSH into the host system as a root user.
  2. Download Python 3.8 and decompress the package by running the following commands:
    cd /opt
    curl -O https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz
    tar -zxvf Python-3.8.12.tgz
  3. Change directory to where you decompressed the Python 3.8 package:
    cd /opt/Python-3.8.12
  4. Add Python bz2 module by running the following command:
    sudo yum install bzip2-devel
  5. Run one of the following command to start installing Python 3.8:
    • If you are installing to the standard location, run the following command
      ./configure --enable-shared
    • If you are installing to a custom location, run the following command:
      ./configure --enable-shared --prefix=[***CUSTOM-INSTALL-PATH***]
  6. Build Python 3.8 as follows:
    1. Run the make command to compile the files:
      make
    2. Run the following command to place the compiled files in the default location or in the custom location that you specified using the --prefix option:
      make altinstall
    3. Copy the shared compiled library files (libpython3.8.so) to the /lib64/ directory:
      cp --no-clobber ./libpython3.8.so* /lib64/
      The --no-clobber option is used to prevent overwriting of files.
    4. Change the permissions of the libpython3.8.so files as follows:
      chmod 755 /lib64/libpython3.8.so*
  7. If you see the error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory error, then run the following command:
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/

If you installed Python 3.8 in a standard location, you can stop here. If you installed Python 3.8 in a custom location using the --prefix option, follow the steps in the next section for providing the custom location to Cloudera Manager.

Enabling Cloudera Manager to use Python 3.8 from the custom location

If you have installed Python 3.8 at a custom location, then you must point Cloudera Manager to that location either by creating a symbolic link using the “alternatives” command or by adding an environment variable to the Cloudera Manager Agent in the systemd service definition files with the full path to the Python 3.8 custom-built binary.

To use the alternatives command, get help by running the command "alternatives --help", or see the Redhat documentation. You should create symbolic links from either /usr/bin/python3.8 or /usr/local/bin/python3.8 to [***CUSTOM-INSTALL-PATH***]/bin/python3.8 where you installed the Python 3.8 package.

To add an environment variable to the Cloudera Manager Agent in the systemd service definition files perform the following steps:
  1. SSH into the host system on which you installed Python 3.8 as a root user.
  2. Open the /usr/lib/systemd/system/cloudera-scm-supervisord.service file for editing.
  3. Add the following line in the cloudera-scm-supervisord.service file under the [Service] section:
    Environment=”PYTHONBIN=[***CUSTOM-INSTAL-PATH***]/bin/python3.8”
    
  4. Open the /usr/lib/systemd/system/cloudera-scm-agent.service file for editing.
  5. Add the following line in the cloudera-scm-agent.service file under the [Service] section:
    Environment=”PYTHONBIN=[***CUSTOM-INSTAL-PATH***]/bin/python3.8”