A.2 Troubleshooting
A.2.1 OML4Py
- Error when importing matplotlib
- Error when importing Python interpreters
- How to add HostAce using cursor in Python?
- Error when installing OML4Py Server for On-Premises Oracle AI Database
Parent topic: Troubleshooting
A.2.1.1 Error when importing matplotlib
matplotlib in a
notebook:%python
import matplotlib.pyplot as plt
plt.style.use('seaborn')
plt.figure(figsize=[10,5])
oml.graphics.boxplot(IRIS[:, :4], notch=True,
showmeans = True,
labels=IRIS.columns[:4])
plt.title('Distribution of IRIS Attributes')
plt.ylabel('cm')Fail to execute line 2: plt.style.use('seaborn')
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/matplotlib/style/core.py", line 137, in use
style = _rc_params_in_file(style)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/matplotlib/__init__.py", line 866, in _rc_params_in_file
with _open_file_or_url(fname) as fd:
File "/usr/local/lib/python3.12/contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/matplotlib/__init__.py", line 843, in _open_file_or_url
with open(fname, encoding='utf-8') as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'seaborn'....
....
OSError: 'seaborn' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)Matplotlib 3.7.0. It affects all Python
3.12.x versions. Specifically, using
plt.style.use('seaborn') was deprecated in Matplotlib
3.6 and removed in 3.7. You will encounter this error
if you're using Python 3.12.x (any point version).
Note:
Ensure that you importMatplotlib ≥ 3.7.0.
Parent topic: OML4Py
A.2.1.2 Error when importing Python interpreters
Issue: The error “Fail to open Python Interpreter” encountered in OML notebooks.
%python
import os os.listdir('/usr/local/lib/python3.12/site-packages')Parent topic: OML4Py
A.2.1.3 How to add HostAce using cursor in Python?
To add HostAce using cursor in Python, run the following command in a Python paragraph:
%python
cursor.execute("BEGIN pyqAppendHostAce('USER_OML', '<adb_instance>.oraclecloudapps.com');
Parent topic: OML4Py
A.2.1.4 Error when installing OML4Py Server for On-Premises Oracle AI Database
Issue: Encountered the following error when installing OML4Py Server for On-Premises Oracle AI Database
SQL> SELECT * FROM sys.pyq_config; NAME VALUE
_____________ _____________________________________________________ PYTHONHOME
/opt/oracle/product/26ai/dbhomeFree/python PYTHONPATH
/opt/oracle/product/26ai/dbhomeFree/oml4py/modules VERSION 2.0
PLATFORM ODB DSWLIST
oml.*;pandas.*;numpy.*;matplotlib.*;sklearn.* SQL> begin 2
sys.pyqScriptCreate('pyqFun1', 'func = lambda: "Hello World from a lambda!"', FALSE, TRUE);
3 end; 4 / PL/SQL procedure successfully completed. SQL> SELECT name, value FROM
table(pyqEval(NULL,'XML','pyqFun1')); SELECT name, value FROM
table(pyqEval(NULL,'XML','pyqFun1')) * ERROR at line 1: ORA-20000: PyQuery error ImportError:
Error importing numpy: you should not try to import numpy from its source directory; please
exit the numpy source tree, and relaunch your python interpreter from there. ORA-06512: at
"PYQSYS.PYQ$EVALIMPL_IN", line 77 ORA-06512: at "PYQSYS.PYQ$EVALIMPL_IN", line 74
ORA-06512: at "SYS.DBMS_SQL", line 1838 ORA-06512: at "PYQSYS.PYQ$ETSTART", line 176
ORA-06512: at "PYQSYS.PYQEVALIMPL", line 54 ORA-06512: at line 1
numpy/ folder.
- Do
cd ..to exit thenumpydirectory. - Now, follow the steps to install OML4Py Server for On-Premises Oracle AI Database again.
Parent topic: OML4Py
A.2.2 OML4R
- How to add rows to a table in the database through an ore.frame
- Unable able to push an object to Autonomous AI Lakehouse from an Oracle Machine Learning Notebook session using OML4R equivalent of OML4Py
Parent topic: Troubleshooting
A.2.2.1 How to add rows to a table in the database through an ore.frame
- Use the Oracle R package.
- Then run an
INSERTinto command to add the rows to the table.
Parent topic: OML4R
A.2.2.2 Unable able to push an object to Autonomous AI Lakehouse from an Oracle Machine Learning Notebook session using OML4R equivalent of OML4Py
Issue: Used this command to push an object to Autonomous AI Lakehouse.
The Oracle Machine Learning for Python command that works:
oml_iris = oml.create(iris_df, table = 'IRIS_OML4PY')
Error
Error in .oci.GetQuery(conn, statement, data = data, prefetch = prefetch, : ORA-06598: insufficient INHERIT PRIVILEGES privilege ORA-06512: at "RQSYS.RQ$ADDRSESSIONREFDBOBJECT", line 1 ORA-06512: at line 1 Traceback: 1. ore.push(iris_df, table = "IRIS_OML4R") 2. ore.push(iris_df, table = "IRIS_OML4R") 3. .ore.addObjects(env, tabName, "table", "purge") 4. .ore.QueryEnv$addRefObjects(objName, objType, objParm) 5. .ore.dbGetQuery(stmt, data = refdbobjs) 6. .ore.QueryEnv$dbGetQuery(qry, noframe = noframe, return = return, . ...) 7. ROracle::dbGetQuery(.ore.con(), qry, ...) 8. ROracle::dbGetQuery(.ore.con(), qry, ...) 9. .local(conn, statement, ...) 10. .oci.GetQuery(conn, statement, data = data, prefetch = prefetch, . bulk_read = bulk_read, bulk_write = bulk_write)
Resolution: Run this command instead:
oml.create != ore.push
Note:
Oracle Machine Learning for Python has its ownpush function. Moreover, the
push function does not take a table argument.
Parent topic: OML4R
A.2.3 OML Notebooks
- How to install third-party packages for both Python and R in Oracle Machine Learning Notebooks
- How to upload data from a .csv file into a Pandas DataFrame
- "Allow Run" button to warn users about potential security threat
- Resource Management in Oracle Machine Learning
Parent topic: Troubleshooting
A.2.3.1 How to install third-party packages for both Python and R in Oracle Machine Learning Notebooks
How to install third-party packages for both Python and R in Oracle Machine Learning Notebooks
Oracle Machine Learning Notebooks in Autonomous AI Lakehouse leverages Conda environment to install third-party packages in Oracle Machine Learning on Oracle Autonomous AI Database Serverless. The ADMIN user creates (installing any needed packages) and uploads the Conda environment to Object Storage. Once uploaded to Object Storage, these environments are available to all non-ADMIN users, who can load them directly into their Oracle Machine Learning Notebooks sessions. These conda environments work with Python and R, whether you are using OML4R (R, SQL, REST APIs) or OML4Py (Python, SQL, REST APIs).
For more information, see Install third-party packages
Parent topic: OML Notebooks
A.2.3.2 How to upload data from a .csv file into a Pandas DataFrame
How to upload data from a .csv file into a Pandas DataFrame
For example, how can I upload data from a .csv file into a Pandas
DataFrame?
IRIS.csv file present in Object Storage, and read into a Pandas
DataFrame, run the following
command:%python
import pandas as pd
import ssl
url="https://objectstorage.us-ashburn-1.oraclecloud.com/n/adwc4pm/b/OML_Data/o/IRIS.csv"
ssl._create_default_https_context = ssl._create_unverified_context
test = pd.read_csv(url)
test.head()read.csv()
instead. Run the following
command:%r
url="https://objectstorage.us-ashburn-1.oraclecloud.com/n/adwc4pm/b/OML_Data/o/IRIS.csv"
test = read.csv(url)
head(test)Parent topic: OML Notebooks
A.2.3.3 "Allow Run" button to warn users about potential security threat
Issue: In Example template notebooks, if there is any javascript in the notebook codes or results, an Allow Run button will be displayed to warn users about potential threat for security reasons. If you don’t want the warning to be displayed, then avoid using javascript in the (example) notebook.
Resolution: For example:
Replace <a
href="https://github.com/oracle/oracle-db-examples/tree/master/machine-learning"
onclick="return !
window.open('https://github.com/oracle/oracle-db-examples/tree/master/machine-learning');">Oracle
Machine Learning GitHub folder</a>
with
<a
href="https://github.com/oracle/oracle-db-examples/tree/master/machine-learning"
target="_blank">Oracle Machine Learning GitHub folder</a>
This also has the same behavior without javascript.
Parent topic: OML Notebooks
A.2.3.4 Resource Management in Oracle Machine Learning
Issue: Does Oracle Machine Learning impose any limitations on traffic or resource usage originating from a single source when triggering embedded Python execution, particularly for heavy workloads or resource-intensive tasks?
Resolution: For each embedded REST execution
call, the Autonomous AI Database broker provisions an individual container from the VM based on the service levels
- Low, Medium, High and releases
it after completion. The resource allocated for the container is limited and the Autonomous AI Database load balancer controls the network traffic.
Parent topic: OML Notebooks
A.2.4 Conda
Parent topic: Troubleshooting
A.2.4.1 Error when loading libraries in Conda environments in Oracle Machine Learning Notebooks
Issue: When loading Conda libraries with statsmodels library and its dependencies, the following error occurs.
Traceback (most recent call last): File "/tmp/python4753125085416874695/zeppelin_python.py", line 145, in <module> import oml, numpy, pandas, scipy, matplotlib, oracledb, sklearn File "/usr/local/lib/python3.12/site-packages/oml/__init__.py", line 43, in <module> from oml.core import * File "/usr/local/lib/python3.12/site-packages/oml/core/__init__.py", line 33, in <module> from .methods import connect File "oml/core/methods.py", line 79, in init oml.core.methods.....
- Adjust the version of statsmodels that is being installed.
- Use the conda
searchcommand to view the library version and the Python build. This includes the Python version. - Use
statsmodels==0.14.0to address this issue.
Parent topic: Conda