I’m trying to use a conda environment in OML Notebooks in Autonomous Database Serverless that contains the statsmodels library and its dependencies. After downloading and activating the environment in a %conda paragraph, I receive the following error when attempting to load statsmodels in a %python paragraph:
“The activated conda environment is not compatible with the OML4PY supporting libraries.”
What can I do to resolve this issue?
The error you’re encountering is likely due to version conflicts between the libraries in your conda environment and the pre-installed supporting libraries in OML Notebooks. Oracle Machine Learning for Python (OML4Py) comes with specific versions of several third-party libraries, including python-oracledb, numpy, pandas, matplotlib, scipy, and scikit-learn.
Installing newer or incompatible versions of these libraries can lead to conflicts. In your case, the installation of statsmodels installs a newer version of pandas, which breaks compatibility with the OML supporting libraries.
To resolve this issue, follow these steps:
Identify Compatible Versions: Use the conda search command to find versions of statsmodels (and any other libraries you want to use) that are compatible with the Python version in OML Notebooks.
First, identify the Python version in use:
%python
import sys
print(sys.version)
3.12.1 (main, Aug 4 2024, 03:24:23) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44.0.3)]
Next, search for the statsmodels library on conda built under this Python version:
%conda
search statsmodels
# Name Version Build Channel
...
...
statsmodels 0.14.0 py312ha883a20_0 pkgs/main
...
...
The output indicates that statsmodels 0.14.0 was built under Python 3.12.
Next, create and upload a new conda environment to Object Storage under ADMIN with the compatible versions you identified. This avoids conflicts with OML4Py’s dependencies.
%conda
create -n myenv -c conda-forge python=3.12.1 statsmodels==0.14.0
upload --overwrite myenv -t application "OML4PY"
Under the non-ADMIN use, download and activate the conda environment and load the statsmodels libary:
%conda
download myenv
activate myenv
%python
import statsmodels
By ensuring that your library versions align with those supported by OML Notebooks, you will avoid compatibility issues.