ErrLookup › Background articles › FileNotFoundError in Python: missing model weights, config files, and paths that only look like file problems
FileNotFoundError in Python: missing model weights, config files, and paths that only look like file problems
FileNotFoundError is Python's built-in signal that a path expected on disk does not exist — but in practice it fires far beyond typos. Across the 249 documented records in this family, it most often appears when machine-learning weights were never downloaded (offline hosts, blocked egress to huggingface.co or modelscope.cn), when settings or .env files are absent at startup, when a renamed or mis-cased file defeats filename-based dispatch, or when a failed network fetch is wrapped and re-raised as this error even though no file was ever involved. Developers meet it on first run of a model, in air-gapped deployments, and in long training jobs whose dataset paths resolve against the wrong base directory.
Distilled from 249 documented records across 67 repositories.
Background
FileNotFoundError (OSError subclass, errno ENOENT) is raised by the interpreter and by explicit `raise FileNotFoundError(...)` guards in library code, and this family spans both origins. The explicit-raise variant dominates the records: libraries deliberately choose this exception to mean "a required artifact is not where the loader resolved it", even when the root cause is upstream. Docling, Deep-Live-Cam, MinerU, immich, and headroom all raise it after a download attempt fails or is skipped, embedding the resolved path and sometimes a prefetch command in the message. From the caller's side it looks identical to a typo'd path, which is why the better-engineered messages (ultralytics's data-loading wrapper, sherlock's manifest fetch, headroom's ONNX candidate loop) insist that you read the chained exception, print the searched locations, or list what actually is on disk.
The largest cluster is ML model artifacts. Weights live on remote hubs (HuggingFace, ModelScope, project-specific URLs) and land in local caches with strict layouts — `models--<org>--<repo>` folders, exact filenames like `gfpgan-1024.onnx`, or paired files like Paddle's required `.json` + `.pdiparams`. The error fires when the artifact was never fetched (offline, no egress, dead URL, unwritable cache), was fetched into a different cache directory than the loader reads, or was fetched in a variant the loader cannot use (an int8 ONNX model an onnxruntime build rejects at execution; an artifact set downloaded for the wrong backend/language pair). LoRA checkpoints add a special case: adapter deltas require the base model to merge into, so a present-but-incomplete model directory still fails.
A second cluster is configuration and derived-data files: settings.yaml profiles resolved by naming convention (private-gpt), .env files located relative to the notebook kernel's cwd (hello-agents), and training-time serialization artifacts like author_map.pkl and file_map.pkl that must match the model checkpoint exactly and cannot be regenerated without corrupting inference. A third cluster is filename-as-API dispatch: ultralytics's build_sam selects an architecture by exact checkpoint suffix, OpenMontage resolves pipelines, schemas, and playbooks by `{name}.yaml` stem lookups, and appending `.yaml` yourself or wrong casing produces a miss. Finally, some FileNotFoundErrors are not about files at all: sherlock wraps any requests failure (DNS, proxy, SSL, timeout) as FileNotFoundError, and yarp's .deb extractor rejects an HTML error page saved with a .deb extension because no `data.tar` member exists — network failures wearing a file error's clothes.
The family also includes concurrency and wrapper shapes: graphify catches the file vanishing between a prior stat and the current one during concurrent rebuilds, and ultralytics's yolov5 data loader re-wraps every scanning failure (permissions, empty directories, encoding errors in list files) as FileNotFoundError with the original chained as __cause__. Where records disagree — e.g. whether a loader auto-downloads (GPEN enhancers do, GFPGAN does not) — the behavior is library-specific, so the fix always starts with checking that specific loader's contract.
Common causes
- Model weights never downloaded or download failed.First use on an offline or egress-blocked machine: huggingface.co, modelscope.cn, or the project's model URL is unreachable, the URL is dead, the cache directory is unwritable or full, or a large file times out partway. The loader re-checks after the download attempt and raises with the resolved path.
- Wrong path, typo, or wrong working directory.Relative paths resolve against the process cwd, not the project root — notebooks started from the wrong folder, dataset paths in YAML resolved against the YAML's parent, or a stale/moved directory. The most common single cause for pure path-miss records.
- Filename-based dispatch miss.Loaders select behavior by exact filename suffix or stem: SAM checkpoints must end in mapped names, pipeline/schema/playbook names must be passed bare (no .yaml extension, case-sensitive). A renamed file, an appended extension (`name.yaml.yaml`), or wrong casing fails before contents are ever read.
- Network failure masquerading as a missing file.Some libraries wrap any fetch failure — DNS, proxy, TLS interception, connect timeout — as FileNotFoundError. The file was never the issue; connectivity to the manifest/model host was.
- Cache layout or format mismatch.The artifact exists but not where or how the loader expects: a cache copied without the `models--*` layout, artifacts fetched for a different backend/language combo, model_format not matching what the repo ships, or a Paddle export missing one of its required .json/.pdiparams pair.
- Missing or misnamed config/settings file.Startup aborts because settings.yaml, a profile YAML, or .env is absent — fresh clones without the copy step, wrong PGPT_SETTINGS_FOLDER, or Windows editors saving `.env.txt`.
- Incomplete or corrupted downloaded file.A partial download, truncation, or an HTML error page saved with the expected extension leaves a file that fails structural checks (no `data.tar` member, no `model_index.json`), so existence checks pass but content checks do not — or the file never lands at all.
- Training/model bundle split across environments.Inference requires the exact pickled vocabulary maps (author_map.pkl, file_map.pkl) used at training time; restoring the checkpoint without them fails, and regenerating from different data would silently corrupt inputs.
What usually fixes it
- Read the error's own evidence first: the resolved path, the list of searched folders, any 'available models' listing, and — most importantly — the chained __cause__ exception, which distinguishes network failure from load failure from execution failure in wrapper-style records.
- For model-artifact cases, get the weights onto disk the way the loader expects: run the prefetch command named in the message (e.g. docling-tools models download), point the loader at the directory that actually contains the cache layout, or pre-seed deployment images so runtime never needs the network.
- For network-shaped cases, verify connectivity and egress to the artifact host (curl the URL, check DNS/proxy/TLS settings, set HTTPS_PROXY or CA bundles), switch to a reachable mirror where the library supports it, or fall back to a local copy of the resource.
- For path and naming cases, confirm exact names (case-sensitive, no double extension, bare stems for name-based lookups), resolve paths against the intended base directory rather than cwd, and use the library's list_*() helpers to see the valid names.
- Make downloads and rebuilds atomic so partial or missing files never carry final names: download to a temp name and rename on completion, verify sizes/hashes after transfer, and pair cache clears with a fresh download before loading.
- Treat maps, splits, checkpoints, and multi-file exports as atomic bundles: archive and restore them together, and assert all required files exist at startup or CI time instead of failing mid-training or mid-request.
Go deeper
- Connection failures: ECONNREFUSED, ECONNRESET, and friends — why connections get refused, reset, or dropped.
- DNS resolution errors: ENOTFOUND and getaddrinfo failures — how hostname lookups fail and how to debug them.
- HTTP status errors: handling 4xx and 5xx responses — how to handle 4xx and 5xx responses properly.
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Documented occurrences
- No loadable ONNX artifact in {model_id}; tried {_onnx_filename_candidates()}(headroomlabs-ai/headroom)
- Failed to download model: {relative_path} from {repo}(opendatalab/MinerU)
- Could not find 'data.tar.*' in {deb_file}.(dotnet/yarp)
- Author map not found, you are loading for inference you need to have an author map!(pytorch/pytorch)
- SoVITS %s 底模缺失,无法加载相应 LoRA 权重(RVC-Boss/GPT-SoVITS)
- {ckpt} is not a supported SAM model. Available models are: {sam_model_map.keys()}(ultralytics/ultralytics)
- Settings file not found for profile '{profile}'. Searched in folders: {_settings_folders} with file name '{profile_file_name}'(zylon-ai/private-gpt)
- Model '{self.vlm_options.repo_id}' not found in artifacts_path. Expected location: {artifacts_path / repo_cache_folder} Available models in {artifacts_path}: {', '.join(available_models) if available_models else 'none'} To fix this issue: 1. Download the model: docling-tools models download-hf-repo {self.vlm_options.repo_id} 2. Or remove --artifacts-path to enable auto-download 3. Or use a different model that exists in your artifacts_path(docling-project/docling)
- {prefix}{p} does not exist(ultralytics/yolov5)
- No baseline with name '{name}' in {RESULTS_DIR}(huggingface/transformers)
- Pipeline manifest not found: {path}(calesthio/OpenMontage)
- 未找到项目目录,请从项目目录或仓库根目录启动 Notebook(datawhalechina/hello-agents)
- graph.json not found: {resolved_path}(Graphify-Labs/graphify)
- 文件{file}不存在(binary-husky/gpt_academic)
- Model file not found: {model_path}(immich-app/immich)
- Schema not found: {path}(calesthio/OpenMontage)
- File map not found, you are loading for inference you need to have a file map!(pytorch/pytorch)
- Model file not found: {model_path}(hacksider/Deep-Live-Cam)
- Invalid mount path: {mount_path}! Please mount manually: {' '.join(mount_command)} or Set init parameter `auto_mount=True`(microsoft/qlib)
- Dataset '{}' for task={} not found ❌(ultralytics/ultralytics)
…and 229 more across the corpus — use search.
Honest provenance: generated on 2026-08-15 from AI-assisted analysis of the linked records. See how records are made.