3 Install OML4Py Client for Linux for Use With Autonomous Database Serverless
You can install and use the OML4Py client for Linux to work with OML4Py in an Oracle Autonomous Database on Serverless Exadata infrastructure.
OML4Py on premises runs on 64-bit platforms only. For supported platforms see Database and System Requirements for OML4Py.
The following instructions tell you how to download install Python, configure your environment, install manage your client credentials, install Oracle Instant Client, and install the OML4Py client:
-
Download the Python 3.12.0 source and untar it:
wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tar.xz tar xvf Python-3.12.0.tar.xz
-
OML4Py requires the presence of the
perl-Env
,libffi-devel
,openssl
,openssl-devel
,tk-devel
,xz-devel
,zlib-devel
,bzip2-devel
,readline-devel
,libuuid-devel
andncurses-devel
libraries. Install these packages as sudo or root user:sudo yum install perl-Env libffi-devel openssl openssl-devel tk-devel xz-devel zlib-devel bzip2-devel readline-devel libuuid-devel ncurses-devel
-
To build Python, enter the following commands, where
PREFIX
is the directory in which you installed Python-3.12.0. Usemake altinstall
to avoid overriding the system default's Python installation.export PREFIX=`pwd`/Python-3.12.0 cd $PREFIX ./configure --prefix=$PREFIX --enable-shared make clean; make make altinstall
-
Set environment variable
PYTHONHOME
and add it to yourPATH
, and set environment variableLD_LIBRARY_PATH
:export PYTHONHOME=$PREFIX export PATH=$PYTHONHOME/bin:$PATH export LD_LIBRARY_PATH=$PYTHONHOME/lib:$LD_LIBRARY_PATH
Create a symbolic link in your
$PYTHONHOME/bin
directory. You need to link it to yourPython 3.12.0 executable, which you can do with the following commands:cd $PYTHONHOME/bin ln -s python3.12 python3
You can now start Python with the
python3
script:python3
pip will return warnings during package installation if the latest version is not installed. You can upgrade the version of pip to avoid these warnings:
python3 -m pip install --upgrade pip
-
Install the Oracle Instant Client for Autonomous Database, as follows:
Download the Oracle Instant Client for your system. Go to the Oracle Instant Client Downloads page and select Instant Client for Linux x86-64. For more instruction see Install Oracle Instant Client for Linux for On-Premises Databases.
For instruction on installing the Oracle instant client for on-premises see Install OML4Py Client for On-Premises Oracle Database.
If you have root access to install an RPM on the client system. Alternatively, you can also download the zip file installer, unzip the file, and add the location of the unzipped file to LD_LIBRARY_PATH as done in next section.
wget https://download.oracle.com/otn_software/linux/instantclient/1914000/oracle-instantclient19.14-basic-19.14.0.0.0-1.x86_64.rpm rpm -ivh oracle-instantclient19.14-basic-19.14.0.0.0-1.x86_64.rpm export LD_LIBRARY_PATH=/usr/lib/oracle/19.14/client64/lib:$LD_LIBRARY_PATH
If you do not have root access to install an RPM on the client system.
https://download.oracle.com/otn_software/linux/instantclient/2340000/instantclient-basic-linux.x64-23.4.0.24.05dbru.zip instantclient-basic-linux.x64-23.4.0.24.05dbru.zip export LD_LIBRARY_PATH=/path/to/instantclient_23_4:$LD_LIBRARY_PATH
-
Download the client credentials (wallet) from your Autonomous database. Create a directory for the Wallet contents. Unzip the wallet zip file to the newly created directory:
Note:
An mTLS connection using the client Wallet is required. TLS connections are not currently supported.mkdir -p mywalletdir unzip Wallet.name.zip -d mywalletdir cd mywalletdir/ ls
README ewallet.p12 ojdbc.properties tnsnames.ora cwallet.sso keystore.jks sqlnet.ora truststore.jks
-
Update
sqlnet.ora
with the wallet location. If you're working behind a proxy firewall, set theSQLNET.USE_HTTPS_PROXY
environment variable toon
:WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY="mywalletdir"))) SSL_SERVER_DN_MATCH=yes SQLNET.USE_HTTPS_PROXY=on
-
Add proxy address information to all service levels in
tnsnames.ora
, and add the connection pools for all service levels. If you are behind a firewall, enter the proxy address and port number to all service levels intnsnames.ora
. You will also need to add three new entries for the AutoML connection pools as shown below.Note:
If the proxy server contains a firewall to terminate connections within a set time period, the database connection will also be terminated.For example,
myadb_medium_pool
is another alias for the connection string withSERVER=POOLED
added to the corresponding one formyadb_medium
.myadb_low = (description= (retry_count=20)(retry_delay=3)(address=(https_proxy=your proxy address here)(https_proxy_port=80)(protocol=tcps)(port=1522)(host=adb.us-sanjose-1.oraclecloud.com))(connect_data=(service_name=qtraya2braestch_myadb_medium.adb.oraclecloud.com))(security=(ssl_server_cert_dn="CN=adb.us-sanjose-1.oraclecloud.com,OU=Oracle ADB SANJOSE,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))
myadb_medium = (description= (retry_count=20)(retry_delay=3)(address=(https_proxy=your proxy address here)(https_proxy_port=80)(protocol=tcps)(port=1522)(host=adb.us-sanjose-1.oraclecloud.com))(connect_data=(service_name=qtraya2braestch_myadb_medium.adb.oraclecloud.com))(security=(ssl_server_cert_dn="CN=adb.us-sanjose-1.oraclecloud.com,OU=Oracle ADB SANJOSE,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))
myadb_high = (description= (retry_count=20)(retry_delay=3)(address=(https_proxy=your proxy address here)(https_proxy_port=80)(protocol=tcps)(port=1522)(host=adb.us-sanjose-1.oraclecloud.com))(connect_data=(service_name=qtraya2braestch_myadb_medium.adb.oraclecloud.com))(security=(ssl_server_cert_dn="CN=adb.us-sanjose-1.oraclecloud.com,OU=Oracle ADB SANJOSE,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))
myadb_low_pool = (description= (retry_count=20)(retry_delay=3)(address=(https_proxy=your proxy address here)(https_proxy_port=80)(protocol=tcps)(port=1522)(host=adb.us-sanjose-1.oraclecloud.com))(connect_data=(service_name=qtraya2braestch_myadb_medium.adb.oraclecloud.com)(SERVER=POOLED))(security=(ssl_server_cert_dn="CN=adb.us-sanjose-1.oraclecloud.com,OU=Oracle ADB SANJOSE,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))
myadb_medium_pool = (description= (retry_count=20)(retry_delay=3)(address=(https_proxy=your proxy address here)(https_proxy_port=80)(protocol=tcps)(port=1522)(host=adb.us-sanjose-1.oraclecloud.com))(connect_data=(service_name=qtraya2braestch_myadb_medium.adb.oraclecloud.com)(SERVER=POOLED))(security=(ssl_server_cert_dn="CN=adb.us-sanjose-1.oraclecloud.com,OU=Oracle ADB SANJOSE,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))
myadb_high_pool = (description= (retry_count=20)(retry_delay=3)(address=(https_proxy=your proxy address here)(https_proxy_port=80)(protocol=tcps)(port=1522)(host=adb.us-sanjose-1.oraclecloud.com))(connect_data=(service_name=qtraya2braestch_myadb_medium.adb.oraclecloud.com)(SERVER=POOLED))(security=(ssl_server_cert_dn="CN=adb.us-sanjose-1.oraclecloud.com,OU=Oracle ADB SANJOSE,O=Oracle Corporation,L=Redwood City,ST=California,C=US")))
-
Set
TNS_ADMIN
environment variable to the wallet directory:export TNS_ADMIN=mywalletdir
-
Install OML4Py library dependencies. The versions listed here are the versions Oracle has tested and supports:
-
pip3.12 install pandas==2.1.1
-
pip3.12 install scipy==1.12.0
-
pip3.12 install matplotlib==3.8.4
-
pip3.12 install oracledb==2.2.0
-
pip3.12 install threadpoolctl==3.1.0
-
pip3.12 install joblib==1.2.0
-
pip3.12 install scikit-learn==1.4.1.post1
-
pip3.12 install setuptools==68.0.0
-
pip3.12 install numpy==1.26.4
-
Install OML4Py client:
Download OML4Py client installation zip file, go to the Oracle Machine Learning for Python Downloads page on the Oracle Technology Network. For more instruction see Install OML4Py Client for Linux for On-Premises Databases
unzip oml4py-client-linux-x86_64-2.0.zip perl -Iclient client/client.pl
Oracle Machine Learning for Python 2.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.12.0 PYTHONHOME ....................... /opt/Python-3.12.0 Existing OML4P module version .... None Operation ........................ Install/Upgrade Proceed? [yes] Processing ./client/oml-2.0-cp312-cp312-linux_x86_64.whl Installing collected packages: oml Successfully installed oml-2.0 Done
-
Start Python and load the
oml
library:python3 import oml
-
Create a database connection. The OML client connects using the wallet. Set the
dsn
andautoml
arguments to thetnsnames
alias in the wallet:oml.connect(user="oml_user", password="oml_user_password", dsn="myadb_medium", automl="myadb_medium_pool")
To provide empty strings for the user and password parameters to connect without exposing your Oracle Machine Learning user credentials in clear text:
oml.connect(user="", password="", dsn="myadb_medium", automl="myadb_medium_pool")
-