{"record":{"id":"874e4d7ad5ac7669","repo":"mlflow/mlflow","slug":"databricks-connect-only-supports-envmanager-vir","errorCode":null,"errorMessage":"Databricks Connect only supports '{_EnvManager.VIRTUALENV}' or '{_EnvManager.UV}' as the environment manager. Got {env_manager}.","messagePattern":"Databricks Connect only supports '(.+?)' or '(.+?)' as the environment manager\\. Got (.+?)\\.","errorType":"error_code","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/models/python_api.py","lineNumber":260,"sourceCode":"    if env_manager == _EnvManager.UV:\n        if not shutil.which(\"uv\"):\n            raise MlflowException(\n                f\"Found '{env_manager}' as env_manager, but the 'uv' command is not found in the \"\n                f\"PATH. {UV_INSTALLATION_INSTRUCTIONS} Alternatively, you can use 'virtualenv' or \"\n                \"'conda' as the environment manager, but note their performances are not \"\n                \"as good as 'uv'.\"\n            )\n    else:\n        _logger.info(\n            f\"It is highly recommended to use `{_EnvManager.UV}` as the environment manager for \"\n            \"predicting with MLflow models as its performance is significantly better than other \"\n            f\"environment managers. {UV_INSTALLATION_INSTRUCTIONS}\"\n        )\n\n    is_dbconnect_mode = is_databricks_connect()\n    if is_dbconnect_mode:\n        if env_manager not in (_EnvManager.VIRTUALENV, _EnvManager.UV):\n            raise MlflowException(\n                f\"Databricks Connect only supports '{_EnvManager.VIRTUALENV}' or '{_EnvManager.UV}'\"\n                f\" as the environment manager. Got {env_manager}.\"\n            )\n        pyfunc_backend_env_root_config = {\n            \"create_env_root_dir\": False,\n            \"env_root_dir\": _PREBUILD_ENV_ROOT_LOCATION,\n        }\n    else:\n        pyfunc_backend_env_root_config = {\"create_env_root_dir\": True}\n\n    def _predict(_input_path: str):\n        return get_flavor_backend(\n            model_uri,\n            env_manager=env_manager,\n            install_mlflow=install_mlflow,\n            **pyfunc_backend_env_root_config,\n        ).predict(\n            model_uri=model_uri,","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/models/python_api.py#L242-L278","documentation":"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.","triggerScenarios":"Running predict/pyfunc spark UDFs while is_databricks_connect() is true and env_manager='conda' or 'local'.","commonSituations":"Migrating legacy Databricks notebooks using conda to Databricks Connect; forgetting that dbconnect mode changes which env managers are valid.","solutions":["Set env_manager to 'uv' or 'virtualenv' when in Databricks Connect mode.","Remove env_manager='conda' and let the model requirements be installed via uv/virtualenv.","Detach Databricks Connect if local conda execution is truly required."],"exampleFix":"// before\npredict(model_uri=uri, input_data=data, env_manager=\"conda\")  # dbconnect session\n// after\npredict(model_uri=uri, input_data=data, env_manager=\"uv\")","handlingStrategy":"validation","validationCode":"from mlflow.models.python_api import _EnvManager\nfrom mlflow.utils.databricks_utils import is_databricks_connect\n\ndef env_ok(env_manager):\n    return not is_databricks_connect() or env_manager in (_EnvManager.VIRTUALENV, _EnvManager.UV)","typeGuard":null,"tryCatchPattern":"try:\n    predict(model_uri=uri, input_data=data, env_manager=em)\nexcept MlflowException as e:\n    if \"Databricks Connect only supports\" in str(e):\n        em = \"uv\"","preventionTips":["In Databricks Connect sessions, restrict env_manager to uv/virtualenv.","Detect dbconnect mode once at startup and clamp the env manager."],"tags":["databricks","environment","spark"],"backgroundTag":"unsupported-environment-manager","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}