4.3 Install the Required Supporting Packages for Linux for On-Premises Databases

Both the OML4Py server and client installations for an on-premises Oracle database require that you also install a set of supporting Python packages, as described below.

Installing required packages on OML4Py client machine

Note:

scikit-learn will be installed from source on Linux 7 and 8 and matplotlib will be installed from source on Linux 7.

Note:

The proxy server is only necessary if the user is behind a firewall. This command installs the pandas library using an example proxy server:
pip3.12 install pandas==2.1.1 --proxy="http://www-proxy.example.com:80"

These steps outline how to install the required Python packages for an on-premises OML4Py client:

  1. Create a file named requirements.txt containing the following content:
    pandas==2.1.1
    scipy==1.12.0
    matplotlib==3.7.2
    oracledb==1.4.2
    joblib==1.2.0
    scikit-learn==1.2.1
    numpy==1.26.4
  2. Install the packages with requirements.txt.
    pip3.12 install -r requirements.txt

Installing required packages on OML4Py server machine

On the OML4Py server machine, all these packages must be installed into $ORACLE_HOME/oml4py/modules so they can be detected by the Embedded Python Execution process. These commands install the commonly required packages on Oracle Linux 7 and Oracle Linux 8.

These steps outline how to install the required Python packages for an on-premises OML4Py server:

  1. Create a file named requirements2.txt containing the following content.
    pandas==2.1.1
    scipy==1.12.0
    oracledb==1.4.2
    joblib==1.2.0
    scikit-learn==1.2.1
    numpy==1.26.4
  2. Install the packages with requirements2.txt. Run the following command, specifying the target directory,$ORACLE_HOME/oml4py/modules:
    pip3.12 install -r requirements2.txt --target=$ORACLE_HOME/oml4py/modules

Build matplotlib 3.7.2 on Oracle Linux 7

  1. Download matplotlib-3.7.2: matplotlib-3.7.2.tar.gz
  2. Extract to and change directory to matplotlib-3.7.2.
    tar xfvz matplotlib-3.7.2.tar.gz
    cd matplotlib-3.7.2/
  3. Build matplotlib module:
    python3 -m pip install setuptools
    python3 -m pip install —upgrade build
    export CFLAGS=-std=c++11
    python3 -m build
    A successful build will return the message:
    Successfully built matplotlib-3.7.2.tar.gz and matplotlib-3.7.2-cp312-cp312-linux_x86_64.whl
  4. Install the module:
    python3 -m pip install ./dist/matplotlib-3.7.2-cp312-cp312-linux_x86_64.whl —target=$ORACLE_HOME/oml4py/modules
Build the scikit-learn 1.2.1 python module on both Oracle Linux 7 and Oracle Linux 8.
  1. Download scikit_learn-1.2.1: scikit_learn-1.2.1.tar.gz
  2. Extract to and change directory to scikit-learn-1.2.1.
    tar xvfz scikit-learn-1.2.1.tar.gz
    cd scikit_learn-1.2.1
  3. Build scikit-learn module:
    pip3.12 install setuptools
    python3 -m pip install —upgrade build
    python3 -m build
    A successful build will return the message:
    Successfully built scikit_learn-1.2.1.tar.gz and scikit_learn-1.2.1-cp312-cp312-linux_x86_64.whl
  4. Install the module:
    pip3.12 install ./dist/scikit_learn-1.2.1-cp312-cp312-linux_x86_64.whl

Note:

The proxy server is only necessary if the user is behind a firewall. This command installs the pandas library using an example proxy server:
pip3.12 install pandas==2.1.1 --proxy="http://www-proxy.example.com:80" --target=$ORACLE_HOME/oml4py/modules

Verify the Package Installation

Load the packages below to ensure they have been installed successfully. Start Python and run the following commands:
python3
Python 3.12.0 (default, Feb 22 2022, 15:13:36)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44.0.3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
import numpy
import pandas
import scipy
import matplotlib
import oracledb
import sklearn

If all the packages are installed successfully, then no errors are returned.