{"record":{"id":"63126dc7e582b1d3","repo":"mlflow/mlflow","slug":"resource-does-not-exist-63126d","errorCode":"RESOURCE_DOES_NOT_EXIST","errorMessage":"Model does not have the \"pyfunc\" flavor","messagePattern":"Model does not have the \"pyfunc\" flavor","errorType":"http","errorClass":"MlflowException","httpStatus":404,"severity":"error","filePath":"mlflow/pyfunc/__init__.py","lineNumber":1151,"sourceCode":"        artifact_uri=model_uri, output_path=dst_path, lineage_header_info=lineage_header_info\n    )\n\n    if not suppress_warnings:\n        model_requirements = _get_pip_requirements_from_model_path(local_path)\n        warn_dependency_requirement_mismatches(model_requirements)\n\n    model_meta = Model.load(os.path.join(local_path, MLMODEL_FILE_NAME))\n\n    if model_meta.metadata and model_meta.metadata.get(MLFLOW_MODEL_IS_EXTERNAL, False) is True:\n        raise MlflowException(\n            \"This model's artifacts are external and are not stored in the model directory.\"\n            \" This model cannot be loaded with MLflow.\",\n            BAD_REQUEST,\n        )\n\n    conf = model_meta.flavors.get(FLAVOR_NAME)\n    if conf is None:\n        raise MlflowException(\n            f'Model does not have the \"{FLAVOR_NAME}\" flavor',\n            RESOURCE_DOES_NOT_EXIST,\n        )\n    model_py_version = conf.get(PY_VERSION)\n    if not suppress_warnings:\n        _warn_potentially_incompatible_py_version_if_necessary(model_py_version=model_py_version)\n\n    _add_code_from_conf_to_system_path(local_path, conf, code_key=CODE)\n    data_path = os.path.join(local_path, conf[DATA]) if (DATA in conf) else local_path\n\n    if isinstance(model_config, str):\n        model_config = _validate_and_get_model_config_from_file(model_config)\n\n    model_config = _get_overridden_pyfunc_model_config(\n        conf.get(MODEL_CONFIG, None), model_config, _logger\n    )\n\n    try:","sourceCodeStart":1133,"sourceCodeEnd":1169,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/pyfunc/__init__.py#L1133-L1169","documentation":"`mlflow.pyfunc.load_model` requires the model's MLmodel file to contain a `python_function` (pyfunc) flavor configuration. If `flavors.get('python_function')` is None, the model was never saved with pyfunc support, so pyfunc loading is impossible and MLflow throws RESOURCE_DOES_NOT_EXIST.","triggerScenarios":"Loading a model_uri that points to a model saved only with non-pyfunc flavors (e.g. only `mlflow.sklearn` with no pyfunc flavor — rare, only flavor-specific loaders), a path that is not an MLflow model at all (missing/incorrect MLmodel), or a corrupt/truncated model directory.","commonSituations":"Passing a run artifact directory that contains raw files rather than a logged model; loading a model from a very old MLflow version or third-party tool that omitted the pyfunc flavor; typos in model_uri pointing at the wrong directory.","solutions":["Verify the target has an MLmodel file listing a `python_function` flavor; if not, re-log with `mlflow.pyfunc.log_model` or the flavor's log_model","Use the flavor-specific loader (e.g. `mlflow.sklearn.load_model`) if the model only has that flavor","Check the model_uri: ensure it points at the model directory itself, not a parent/subfolder","Re-save the model with a current MLflow version if produced by an old or third-party exporter"],"exampleFix":"// before\nmlflow.pyfunc.load_model(\"runs:/abc/raw_artifacts\")  # no MLmodel/pyfunc flavor\n// after\nmlflow.pyfunc.log_model(\"model\", python_model=my_model)  # re-log with pyfunc\nmlflow.pyfunc.load_model(\"runs:/abc/model\")","handlingStrategy":"validation","validationCode":"from mlflow.models import Model\nmeta = Model.load(os.path.join(local_path, \"MLmodel\"))\nassert \"python_function\" in meta.flavors, f\"flavors available: {list(meta.flavors)}\"","typeGuard":"def has_pyfunc_flavor(model_path) -> bool:\n    from mlflow.models import Model\n    return \"python_function\" in Model.load(os.path.join(model_path, \"MLmodel\")).flavors","tryCatchPattern":"try:\n    model = mlflow.pyfunc.load_model(uri)\nexcept MlflowException as e:\n    if 'does not have the \"python_function\" flavor' in str(e):\n        model = mlflow.sklearn.load_model(uri)  # flavor-specific fallback\n    else:\n        raise","preventionTips":["Verify the MLmodel file exists and lists python_function before pyfunc loading","Always log models via log_model APIs which add the pyfunc flavor","Confirm model_uri points at the model directory, not a parent folder","Re-save old/third-party models with current MLflow"],"tags":["pyfunc","missing-flavor","model-loading"],"backgroundTag":"missing-flavor-in-model","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}