mlflow/mlflow · error · MlflowException

Databricks Connect only supports '{_EnvManager.VIRTUALENV}'

Error message

Databricks Connect only supports '{_EnvManager.VIRTUALENV}' or '{_EnvManager.UV}' as the environment manager. Got {env_manager}.

What it means

In Databricks Connect (dbconnect) mode, model environments can only be prebuilt under virtualenv or uv; conda or local are unsupported. MLflow raises MlflowException when a different env_manager is used because Spark UDF execution requires the prebuilt-env root layout these managers provide.

Source

Thrown at mlflow/models/python_api.py:260

    if env_manager == _EnvManager.UV:
        if not shutil.which("uv"):
            raise MlflowException(
                f"Found '{env_manager}' as env_manager, but the 'uv' command is not found in the "
                f"PATH. {UV_INSTALLATION_INSTRUCTIONS} Alternatively, you can use 'virtualenv' or "
                "'conda' as the environment manager, but note their performances are not "
                "as good as 'uv'."
            )
    else:
        _logger.info(
            f"It is highly recommended to use `{_EnvManager.UV}` as the environment manager for "
            "predicting with MLflow models as its performance is significantly better than other "
            f"environment managers. {UV_INSTALLATION_INSTRUCTIONS}"
        )

    is_dbconnect_mode = is_databricks_connect()
    if is_dbconnect_mode:
        if env_manager not in (_EnvManager.VIRTUALENV, _EnvManager.UV):
            raise MlflowException(
                f"Databricks Connect only supports '{_EnvManager.VIRTUALENV}' or '{_EnvManager.UV}'"
                f" as the environment manager. Got {env_manager}."
            )
        pyfunc_backend_env_root_config = {
            "create_env_root_dir": False,
            "env_root_dir": _PREBUILD_ENV_ROOT_LOCATION,
        }
    else:
        pyfunc_backend_env_root_config = {"create_env_root_dir": True}

    def _predict(_input_path: str):
        return get_flavor_backend(
            model_uri,
            env_manager=env_manager,
            install_mlflow=install_mlflow,
            **pyfunc_backend_env_root_config,
        ).predict(
            model_uri=model_uri,

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Set env_manager to 'uv' or 'virtualenv' when in Databricks Connect mode.
  2. Remove env_manager='conda' and let the model requirements be installed via uv/virtualenv.
  3. Detach Databricks Connect if local conda execution is truly required.

Example fix

// before
predict(model_uri=uri, input_data=data, env_manager="conda")  # dbconnect session
// after
predict(model_uri=uri, input_data=data, env_manager="uv")
Defensive patterns

Strategy: validation

Validate before calling

from mlflow.models.python_api import _EnvManager
from mlflow.utils.databricks_utils import is_databricks_connect

def env_ok(env_manager):
    return not is_databricks_connect() or env_manager in (_EnvManager.VIRTUALENV, _EnvManager.UV)

Try / catch

try:
    predict(model_uri=uri, input_data=data, env_manager=em)
except MlflowException as e:
    if "Databricks Connect only supports" in str(e):
        em = "uv"

Prevention

When it happens

Trigger: Running predict/pyfunc spark UDFs while is_databricks_connect() is true and env_manager='conda' or 'local'.

Common situations: Migrating legacy Databricks notebooks using conda to Databricks Connect; forgetting that dbconnect mode changes which env managers are valid.

Related errors


AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29). Data as JSON: /api/errors/874e4d7ad5ac7669. Report an issue: GitHub.