Trying to load an MLflow model using a Python script returns Py4JJavaError

Upgrade MLflow to version 2.15.0 or above.

Written by anshuman.sahu

Last published at: September 30th, 2024

Problem

While running a job using a Python script to load an MLflow model, you encounter the following error message.

Py4JJavaError: An error occurred while calling o422.get.: java.util.NoSuchElementException: None.get

Cause

MLflow has an issue in versions below 2.15.0. It is resolved in 2.15.0 and above. 

Solution

Upgrade MLflow to version 2.15.0 or above. 

 

Verify the current MLflow version.

import mlflow
print(mlflow.__version__)

 

If it’s an older version, or you use a Databricks Runtime version that comes with an older version of MLflow, install the latest version of MLflow in your Databricks cluster.

 

  1. Go to your workspace and select the cluster where you want to install the latest version of MLflow. 
  2. Click the Libraries tab and then click Install New.
  3. In the Install Library dialog box, select PyPI as the library source and enter MLflow in the Package field. Also make sure to check Attach to cluster.
  4. Click Install to install the latest version of MLflow.