{"record":{"id":"d3d2b6ca96c4d296","repo":"huggingface/transformers","slug":"can-t-load-feature-extractor-for-pretrained-mode","errorCode":null,"errorMessage":"Can't load feature extractor for '{pretrained_model_name_or_path}'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure '{pretrained_model_name_or_path}' is the correct path to a directory containing a {FEATURE_EXTRACTOR_NAME} file","messagePattern":"Can't load feature extractor for '(.+?)'\\. If you were trying to load it from 'https://huggingface\\.co/models', make sure you don't have a local directory with the same name\\. Otherwise, make sure '(.+?)' is the correct path to a directory containing a (.+?) file","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"error","filePath":"src/transformers/feature_extraction_utils.py","lineNumber":509,"sourceCode":"                    pretrained_model_name_or_path,\n                    filename=feature_extractor_file,\n                    cache_dir=cache_dir,\n                    force_download=force_download,\n                    proxies=proxies,\n                    local_files_only=local_files_only,\n                    token=token,\n                    user_agent=user_agent,\n                    revision=revision,\n                    subfolder=subfolder,\n                    _raise_exceptions_for_missing_entries=False,\n                )\n            except OSError:\n                # Raise any environment error raise by `cached_file`. It will have a helpful error message adapted to\n                # the original exception.\n                raise\n            except Exception:\n                # For any other exception, we throw a generic error.\n                raise OSError(\n                    f\"Can't load feature extractor for '{pretrained_model_name_or_path}'. If you were trying to load\"\n                    \" it from 'https://huggingface.co/models', make sure you don't have a local directory with the\"\n                    f\" same name. Otherwise, make sure '{pretrained_model_name_or_path}' is the correct path to a\"\n                    f\" directory containing a {FEATURE_EXTRACTOR_NAME} file\"\n                )\n\n        # Load feature_extractor dict. Priority goes as (nested config if found -> image processor config)\n        # We are downloading both configs because almost all models have a `processor_config.json` but\n        # not all of these are nested. We need to check if it was saved recently as nested or if it is legacy style\n        feature_extractor_dict = None\n        if resolved_processor_file is not None:\n            processor_dict = safe_load_json_file(resolved_processor_file)\n            if \"feature_extractor\" in processor_dict or \"audio_processor\" in processor_dict:\n                feature_extractor_dict = processor_dict.get(\"feature_extractor\", processor_dict.get(\"audio_processor\"))\n\n        if resolved_feature_extractor_file is not None and feature_extractor_dict is None:\n            feature_extractor_dict = safe_load_json_file(resolved_feature_extractor_file)\n","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/feature_extraction_utils.py#L491-L527","documentation":"Thrown by FeatureExtractionMixin.from_pretrained when fetching the feature extractor config from the Hub or local path fails with a non-OSError exception (OSError from cached_file is re-raised as-is with its own message). It is a generic wrapper indicating the config download/resolution step exploded unexpectedly. The message also hints at the classic failure where a local directory shadows a Hub model id.","triggerScenarios":"Calling FeatureExtractor.from_pretrained / AutoFeatureExtractor.from_pretrained where get_cached_file raises something other than OSError: HTTP errors not mapped to OSError, malformed proxies, an invalid revision/subfolder, or a local directory named identically to a Hub model that lacks a feature extractor file.","commonSituations":"Offline machine without HF_HUB_OFFLINE set, typo'd model id, corporate proxy intercepting huggingface.co, a local folder (e.g. './wav2vec2-base') shadowing the repo id, or requesting a revision/subfolder that does not contain preprocessor_config.json.","solutions":["Inspect the chained exception (__cause__/__context__) to see the real underlying error before this generic wrapper","Verify the model id exists on https://huggingface.co/models and hosts a feature extractor file (preprocessor_config.json or feature_extractor_config.json)","Rename or move any local directory whose name equals the model id so it cannot shadow the Hub repo","Check connectivity/proxy settings (HTTPS_PROXY, HF_ENDPOINT) or enable HF_HUB_OFFLINE=1 when working purely from cache","Pass revision= or subfolder= explicitly if the file lives outside the default branch/root"],"exampleFix":"// before\nfe = Wav2Vec2FeatureExtractor.from_pretrained(\"facebook/wav2vec2-base-960h-typo\")\n// after (from a local directory that contains preprocessor_config.json)\nfe = Wav2Vec2FeatureExtractor.from_pretrained(\"./models/wav2vec2-base-960h\")","handlingStrategy":"try-catch","validationCode":"from huggingface_hub import list_repo_files\nimport os\n\ndef feature_extractor_files_available(model_id: str, token=None) -> bool:\n    if os.path.isdir(model_id):\n        return any(f in os.listdir(model_id) for f in (\"preprocessor_config.json\", \"feature_extractor_config.json\"))\n    try:\n        files = list_repo_files(model_id, token=token)\n    except Exception:\n        return False\n    return any(f in files for f in (\"preprocessor_config.json\", \"feature_extractor_config.json\", \"processor_config.json\"))","typeGuard":null,"tryCatchPattern":"from transformers import AutoFeatureExtractor\ntry:\n    fe = AutoFeatureExtractor.from_pretrained(model_id)\nexcept OSError as e:\n    # chained exception carries the root cause\n    logging.error(\"feature extractor load failed: %s\", e)\n    raise","preventionTips":["Avoid naming local directories the same as Hub model ids you intend to load","Pin revision= for reproducible loads","Pre-download configs with huggingface-cli and set HF_HUB_OFFLINE=1 in air-gapped environments"],"tags":["python","transformers","feature-extractor","hub-download","from-pretrained"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}