Enable the Bridge between OML and Python on Linux

  1. Install/build Python 3.8.10 , Numpy 1.22.1, and scipy 1.6.1.
  2. Enable omlpythonbridge toolbox loading.
    Add the command loadtoolbox omlpythonbridge in the file <INSTALLATION_HOME>\OpenMatrix\scripts\loadtoolboxes.oml.
  3. In the file <INSTALLATION_HOME>\OpenMatrix\scripts\run_omlconsole.sh, add the following:
    1. Set the environment variable OML_PYTHONHOME to point to Python home.
      export OML_PYTHONHOME=/usr/local/python3.8.10
    2. Add the Python library file (libpython3.8m.so.1.0) location to the environment variable “LD_LIBRARY_PATH.”
      export LD_LIBRARY_PATH=/usr/local/python3.8.10/lib:$LD_LIBRARY_PATH
    3. Set the environment variable LD_PRELOAD to point to libpython3.8.so.1.0.
      export LD_PRELOAD=/usr/local/Python38/lib/libpython3.8.so.1.0
    Note: omlpythonbridge toolbox is built using Python binaries, which are built using RedHat Linux 6.6 devtoolset-3 compilers, Intel 2016 Update 2 Fortran and C++ compilers. It is advised to use Python binaries built using the same compiler versions.
    Note: OpenMatrix binaries are built using RedHat Linux 6.6 devtoolset-3 compilers, Intel 2016 Update 2 Fortran and C++ compilers with:
    • Compilation Options: g++ -O2 -fPIC -std=c++11 -DLINUX -DOS_UNIX
    • Link options: g++ -shared -Wl,-Bsymbolic –fPIC
    Note: Verified omlpythonbridge toolbox using Python 3.8.10 built from source. Installed Numpy, Scipy, Matplotlib using pip.

    The steps to build Python and install modules for RedHat 8.4 are:

    1. yum install zlib*
    2. yum install openssl-devel
    3. cd /opt
    4. wget https://www.python.org/ftp/python/3.8.10/Python-3.8.10.tgz
    5. tar xzf Python-3.8.10.tgz
    6. cd Python-3.8*/
    7. ./configure --enable-shared --prefix=/usr/local/python38
    8. make altinstall
    9. export LD_LIBRARY_PATH=/usr/local/python38/lib:$LD_LIBRARY_PATH
    10. cd /usr/local/python38/bin
    11. python3.8 -m pip install --upgrade pip
    12. python3.8 -m pip install numpy==1.22.1
    13. python3.8 -m pip install scipy==1.6.1
    14. python3.8 -m pip install matplotlib==3.3.0