This is an update of previous post on How to install OML4Py Client on Ubuntu , this time Oracle Linux 9.
Install OML4Py on Oracle Linux
The goal here is to have OML4Py 2.1 available in order to export embedding models to ONNX format. To follow this procedure you need to have a free Oracle Account, you will be offered to create one when you try to access https://edelivery.oracle.com/ later.
This installation is divided in parts:
- Install a specific version of Python
- Install Oracle Instant Client
- Download OML4Py and install specific Python packages it requires
- Install OML4Py
One advice for future releases of OML4Py is to download it first (see below how) and inspect a file to verify what specific Python version OML4Py actually requires, so you don’t waste time installing the wrong Python version, look for line requires Python ...in file client/OML4PInstallShared.pm As of today the documentation in chapter 3 says it requires 3.12.0, but on version 2.1_03142025 (see oml4py.ver) it requires 3.12.3, this is also reflected in table 4-1 in the current manual.
For any testing against Oracle AI Database, use the latest Free version unless you have access to another edition with 26ai.
Download, compile and install Python 3.12.6
mkdir -p $HOME/Python
cd $HOME/Python
curl -O https://www.python.org/ftp/python/3.12.6/Python-3.12.6.tgz
tar xvf Python-3.12.6.tgz
cd Python-3.12.6
Install packages that OML4Py needs plus libaio that Instantclient requires:
sudo dnf install perl-Env libffi-devel openssl openssl-devel tk-devel xz-devel zlib-devel bzip2-devel readline-devel libuuid-devel ncurses-devel libaio
Configure, compile, and install:
./configure --enable-shared --prefix=$HOME/Python/Python-3.12.6 --enable-optimizations
make clean; make
make altinstall
Add links
cd $HOME/Python/Python-3.12.6/bin/
ln -s python3.12 python3
ln -s python3.12 python
Download Instant Client
Go to https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html and find the latest version on 26ai, the first line Basic Package (ZIP)
The link at the time this post was written: https://download.oracle.com/otn_software/linux/instantclient/2326000/instantclient-basic-linux.x64-23.26.0.0.0.zip
mkdir -p $HOME/Oracle
cd $HOME/Oracle
curl -O https://download.oracle.com/otn_software/linux/instantclient/2326000/instantclient-basic-linux.x64-23.26.0.0.0.zip
unzip instantclient-basic-linux.x64-23.26.0.0.0.zip
rm instantclient-basic-linux.x64-23.26.0.0.0.zip
Create a file with environment variables to be used later
cd $HOME/Python
mkdir OML4Py
cd OML4Py
vi env_vars
Put this in a file, the filename env_vars is used here:
PYTHONHOME=$HOME/Python/Python-3.12.6
PATH=$PYTHONHOME/bin:$PATH
LD_LIBRARY_PATH=$PYTHONHOME/lib:$HOME/Oracle/instantclient_23_26:$LD_LIBRARY_PATH
export PYTHONHOME PATH LD_LIBRARY_PATH
This file will be sourced by executing . env_vars later.
Download OML4Py
Go to https://www.oracle.com/database/technologies/oml4py-downloads.html
Click the link for OML4Py 2.1.0, it will take you to edelivery.oracle.com and ask you to login. Accept the Oracle License Agreement and click the link for V1048628-01.zip. Transfer to the machine where you are installing OML4Py if different. I have put it in $HOME/tmp
cd $HOME/Python/OML4Py
unzip $HOME/tmp/V1048628-01.zip
Source the file created earlier, create a virtual environment, and upgrade pip
. $HOME/Python/OML4Py/env_vars
python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip
Add this to a new file called requirements.txt
pandas==2.2.2
setuptools==70.0.0
scipy==1.14.0
matplotlib==3.8.4
oracledb==2.4.1
scikit-learn==1.5.1
numpy==2.0.1
onnxruntime==1.20.0
onnxruntime-extensions==0.12.0
onnx==1.17.0
torch==2.6.0
transformers==4.49.0
sentencepiece==0.2.0
Install the packages with
pip install -r requirements.txt
Install the client package with:
pip3 install client/oml-2.1-cp312-cp312-linux_x86_64.whl
Finally install OML4Py with
perl -Iclient client/client.pl
When running this it is normal to wait a few seconds on the line Checking OML4P version … It is starting Python and tries to load the oml-library.
Answer yes and complete the installation. This is from a successful installation:
Oracle Machine Learning for Python 2.1 Client.
Copyright (c) 2018, 2025 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.6
PYTHONHOME ....................... /home/opc/Python/OML4Py/venv
Existing OML4P module version .... 2.1
Operation ........................ Install/Upgrade
Proceed? [yes]
Found existing installation: oml 2.1
Uninstalling oml-2.1:
Successfully uninstalled oml-2.1
Processing ./client/oml-2.1-cp312-cp312-linux_x86_64.whl
Installing collected packages: oml
Successfully installed oml-2.1
Done
Try the new installation and check the version and path for the package in Python. Run this in Python:
import oml
oml.__version__
oml.__path__
I am going to use this to export available pretrained models to ONNX format, this code lists the models available:
from oml.utils import ONNXPipeline, ONNXPipelineConfig
for i in ONNXPipelineConfig.show_preconfigured():
print(i)
This shows the available templates:
ONNXPipelineConfig.show_templates()
This exports one of the models to a file:
pipeline = ONNXPipeline(model_name="sentence-transformers/all-mpnet-base-v2")
pipeline.export2file("all_mpnet_base_v2",output_dir=".")
The first time you run this it will download a bunch of files and place them under $HOME/.cache/OML. They allocate around 420 MB. After this you should have a file called all_mpnet_base_v2.onnx in your current directory.
If you are reading this because you will import the model to an Oracle AI Database you can now transfer the file to a directory on the database server. In the database you will define a directory and load the model to the database as explained in Chapter 3, SQL Quick Start Using a Vector Embedding Model Uploaded into the Database in the AI Vector Search User’s Guide .
This blogpost will be mentioned in my presentation at the DOAG 2025 Conference and at UKOUG Conference Discovery 2025 , see agenda .