mlflow/mlflow · error · MlflowException
RESOURCE_DOES_NOT_EXIST
RESOURCE_DOES_NOT_EXIST
Error message
Model does not have the "pyfunc" flavor
What it means
`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.
Source
Thrown at mlflow/pyfunc/__init__.py:1151
artifact_uri=model_uri, output_path=dst_path, lineage_header_info=lineage_header_info
)
if not suppress_warnings:
model_requirements = _get_pip_requirements_from_model_path(local_path)
warn_dependency_requirement_mismatches(model_requirements)
model_meta = Model.load(os.path.join(local_path, MLMODEL_FILE_NAME))
if model_meta.metadata and model_meta.metadata.get(MLFLOW_MODEL_IS_EXTERNAL, False) is True:
raise MlflowException(
"This model's artifacts are external and are not stored in the model directory."
" This model cannot be loaded with MLflow.",
BAD_REQUEST,
)
conf = model_meta.flavors.get(FLAVOR_NAME)
if conf is None:
raise MlflowException(
f'Model does not have the "{FLAVOR_NAME}" flavor',
RESOURCE_DOES_NOT_EXIST,
)
model_py_version = conf.get(PY_VERSION)
if not suppress_warnings:
_warn_potentially_incompatible_py_version_if_necessary(model_py_version=model_py_version)
_add_code_from_conf_to_system_path(local_path, conf, code_key=CODE)
data_path = os.path.join(local_path, conf[DATA]) if (DATA in conf) else local_path
if isinstance(model_config, str):
model_config = _validate_and_get_model_config_from_file(model_config)
model_config = _get_overridden_pyfunc_model_config(
conf.get(MODEL_CONFIG, None), model_config, _logger
)
try:View on GitHub (pinned to 6a27f2decc)
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
Example fix
// before
mlflow.pyfunc.load_model("runs:/abc/raw_artifacts") # no MLmodel/pyfunc flavor
// after
mlflow.pyfunc.log_model("model", python_model=my_model) # re-log with pyfunc
mlflow.pyfunc.load_model("runs:/abc/model") Defensive patterns
Strategy: validation
Validate before calling
from mlflow.models import Model
meta = Model.load(os.path.join(local_path, "MLmodel"))
assert "python_function" in meta.flavors, f"flavors available: {list(meta.flavors)}" Type guard
def has_pyfunc_flavor(model_path) -> bool:
from mlflow.models import Model
return "python_function" in Model.load(os.path.join(model_path, "MLmodel")).flavors Try / catch
try:
model = mlflow.pyfunc.load_model(uri)
except MlflowException as e:
if 'does not have the "python_function" flavor' in str(e):
model = mlflow.sklearn.load_model(uri) # flavor-specific fallback
else:
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Model is missing metadata.
- Unable to retrieve base model object from pyfunc.
- BAD_REQUEST
- Invalid model type: '{model_type}'. Must be one of {list(mod
- Failed to load base model '{effective_base_model}'. If the m
AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29).
Data as JSON: /api/errors/63126dc7e582b1d3.
Report an issue: GitHub.