3.5.1.2 Install OML4Py Client for Linux for On-Premises Databases
Instructions for installing the OML4Py client for Linux for use with an on-premises Oracle database.
Prerequisites
To download and install the on-premises OML4Py client, the following are required:
- A connection to the internet.
- Write permission on the directory in which you are installing the client.
- Perl 5.8 or higher installed on your system.
- Python 3.9.5. To know more about downloading and installing Python 3.9.5, see Build and Install Python for Linux for On-Premises Databases
To use the OML4Py client to connect to an on-premises Oracle database, the following are required:
- Oracle Instant Client must be installed on the client machine.
- The OML4Py server must be installed on the on-premises database server.
Download and Extract the OML4Py Client Installation File
To download and extract the OML4Py client installation file, do the following:
- Download the client installation zip file.
- Go to the Oracle Machine Learning for Python Downloads page on the Oracle Technology Network.
- Accept the license agreement and select Oracle Machine Learning for Python Downloads (v1.0).
- Select Oracle Machine Learning for Python Client Install for Oracle Database on Linux 64 bit.
- Save the zip file to an accessible directory. These instructions use a directory
named
oml4py
, but you can download the zip file to any location accessible to the user installing theoml4py
client.
- Go to the directory to which you downloaded the zip file and unzip the
file.
cd oml4py unzip oml4py-client-linux-x86_64-1.0.zip
The contents are extracted to a subdirectory named
client
, which contains these four files:OML4PInstallShared.pm
oml-1.0-cp39-cp39-linux_x86_64.whl
client.pl
oml4py.ver
View the Optional Arguments to the Client Installation Perl Script
In the directory that contains the downloaded the installation zip file (oml4py
in these instructions), run the client installation Perl script with the --help
option to display the arguments to the client installation Perl script.
The following command displays the available installation options:
$ perl -Iclient client/client.pl --help Oracle Machine Learning for Python 1.0 Client. Copyright (c) 2018, 2022 Oracle and/or its affiliates. All rights reserved. Usage: client.pl [OPTION]... Install, upgrade, or uninstall OML4P Client. -i, --install install or upgrade (default) -u, --uninstall uninstall -y never prompt --ask interactive mode (default) --no-embed do not install embedded python functionality --no-automl do not install automl module --no-deps turn off dependencies checking --target <dir> install client into <dir>
By default, the installation script installs the Embedded Python Execution and
AutoML modules. If you don't want to install these modules, then you can use the
--no-embed
and --no-automl
flags, respectively.
Also by default, the installation script checks for the existence and version of each of the supporting packages that the OML4Py client requires. If a required package is missing or does not meet the version requirement, the installation script displays an error message and exits. You can skip the dependency checking in the client installation by using the --no-deps
flag. However, to use the oml
module, you need to have installed acceptable versions of all of the supporting packages.
For a list of the required dependencies, see Install the Required Supporting Packages for Linux for On-Premises Databases.
Run the OML4Py Client Installation Script
To install the OML4Py client, do the following:
- In the directory that contains the extracted client installation Perl script, run
the script. The following command runs the Perl script in the current
directory:
$ perl -Iclient client/client.pl
Alternatively, the following command runs the Perl script with the target directory specified:
perl -Iclient client/client.pl --target path_to_target_dir
The
--target
flag is optional, if you don't want to install it to the current directory.When the script displays
Proceed?
, entery
oryes
.If you use the
--target <dir>
argument to install theoml
module to the specified directory, then add that location to environment variablePYTHONPATH
so that Python can find the module:export PYTHONPATH=path_to_target_dir
The command displays the following:
$ perl -Iclient client/client.pl Oracle Machine Learning for Python 1.0 Client. Copyright (c) 2018, 2022 Oracle and/or its affiliates. All rights reserved. Checking platform .................. Pass Checking Python .................... Pass Checking dependencies .............. Pass Checking OML4P version ............. Pass Current configuration Python Version ................... 3.9.5 PYTHONHOME ....................... /opt/Python-3.9.5 Existing OML4P module version .... None Operation ........................ Install/Upgrade Proceed? [yes] Processing ./client/oml-1.0-cp39-cp39-linux_x86_64.whl Installing collected packages: oml Successfully installed oml-1.0
- To verify that
oml
modules are successfully installed and are ready to use, start Python and importoml
. At the Linux prompt, enterpython3
.python3
At the Python prompt, enter
import oml
import oml
The output is similar to the following:
$ python3 Python 3.9.5 (default, Feb 23 2022, 17:12:33) [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 oml >>>
- Display the location of the installation directory.
If you didn't use the
--target <dir>
argument, then the installedoml
modules are stored under$PYTHONHOME/lib/python3.9/site-packages/
. Again, you must have write permission for the target directory.In Python, after importing the
oml
module, you can display the directory in which the client is installed. At the Python prompt, enter:oml.__path__
Connect to the OML4Py Server
Start Python, import oml
, and create a connection to your OML4Py server using an appropriate password, hostname, and system identifier. The following example uses oml_user as the user and has example argument values. Replace the username and other argument values with the values for your user and database.
import oml
oml.connect(user='oml_user', password='oml_user_password', host=myhost,
port=1521, sid=mysid)
After connecting, you can run any of the examples in this publication. For example, you could run Example 6-8.
Note:
To use the Embedded Python Execution examples, you must have installed the OML4Py client with the Embedded Python Execution option enabled.To use the Automatic Machine Learning (AutoML) examples, you must specify a running connection pool on the server in the automl
argument in an oml.connect
invocation.