{"record":{"id":"63d9d3c6085b7fc2","repo":"huggingface/transformers","slug":"can-t-load-the-configuration-of-pretrained-model","errorCode":null,"errorMessage":"Can't load the configuration of '{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 {configuration_file} file","messagePattern":"Can't load the configuration of '(.+?)'\\. 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/configuration_utils.py","lineNumber":822,"sourceCode":"                    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                    _commit_hash=commit_hash,\n                )\n                if resolved_config_file is None:\n                    return None, kwargs\n                commit_hash = extract_commit_hash(resolved_config_file, commit_hash)\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 the configuration of '{pretrained_model_name_or_path}'. If you were trying to load it\"\n                    \" from 'https://huggingface.co/models', make sure you don't have a local directory with the same\"\n                    f\" name. Otherwise, make sure '{pretrained_model_name_or_path}' is the correct path to a directory\"\n                    f\" containing a {configuration_file} file\"\n                )\n\n        try:\n            if gguf_file:\n                config_dict = load_gguf_checkpoint(resolved_config_file, return_tensors=False)[\"config\"]\n            else:\n                # Load config dict\n                config_dict = cls._dict_from_json_file(resolved_config_file)\n\n            config_dict[\"_commit_hash\"] = commit_hash\n        except (json.JSONDecodeError, UnicodeDecodeError):\n            raise OSError(f\"It looks like the config file at '{resolved_config_file}' is not a valid JSON file.\")\n\n        if is_local:","sourceCodeStart":804,"sourceCodeEnd":840,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/configuration_utils.py#L804-L840","documentation":"Generic OSError raised by PreTrainedConfig.from_pretrained / get_config_dict when any unexpected exception (not an OSError) occurs while resolving the config file for pretrained_model_name_or_path. It wraps failures such as HTTP errors, gated-repo access denials, or malformed repo ids into a single 'can't load the configuration' message pointing at the Hub and at local-directory shadowing.","triggerScenarios":"AutoConfig.from_pretrained(\"org/typo-name\") with a typo; a gated/private repo without valid credentials; a request that fails with a non-OSError exception (e.g. requests.HTTPError); a local folder whose name matches the repo id so the Hub path is never used.","commonSituations":"Offline machines, expired Hugging Face tokens, gated models (Llama-style) not yet granted, corporate proxies rewriting responses, or a local directory named exactly like the model id.","solutions":["Verify the model id spelling with huggingface-cli search or the Hub web UI.","If the repo is gated/private, run `huggingface-cli login` (or set HF_TOKEN) and request access.","If you have a local copy, pass its absolute path instead of the repo id, or rename the local directory that shadows the repo id.","For offline use, point HF_HUB_OFFLINE=1 at a populated cache or pass local_files_only=True."],"exampleFix":"// before\nconfig = AutoConfig.from_pretrained(\"meta-llama/Llama-3-8b\")  # OSError: can't load\n\n// after\nfrom huggingface_hub import login\nlogin()\nconfig = AutoConfig.from_pretrained(\"meta-llama/Meta-Llama-3-8B\")","handlingStrategy":"validation","validationCode":"from huggingface_hub import model_info\ntry:\n    model_info(\"org/name\", token=HF_TOKEN)  # raises clearly on typo/gating\nexcept Exception as e:\n    raise RuntimeError(f\"Cannot access org/name on the Hub: {e}\")","typeGuard":null,"tryCatchPattern":"from transformers.utils import cached_file\ntry:\n    AutoConfig.from_pretrained(name)\nexcept OSError as e:\n    if \"Can't load the configuration\" in str(e):\n        # fall back to local snapshot or prompt for credentials\n        config = AutoConfig.from_pretrained(local_path)","preventionTips":["Run huggingface-cli login and export HF_TOKEN in automated environments before loading hub models.","Pin exact revision (revision=commit_sha) and pre-download with huggingface-cli download to get precise failures.","Avoid naming local directories the same as hub repo ids."],"tags":["hub","network","config","from-pretrained"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}