{"record":{"id":"fbf42e0db42c6201","repo":"ultralytics/yolov5","slug":"prefix-error-loading-data-from-path-e-n-help","errorCode":null,"errorMessage":"{prefix}Error loading data from {path}: {e}\\n{HELP_URL}","messagePattern":"(.+?)Error loading data from (.+?): (.+?)\\\\n(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"utils/dataloaders.py","lineNumber":524,"sourceCode":"            f = []  # image files\n            for p in path if isinstance(path, list) else [path]:\n                p = Path(p)  # os-agnostic\n                if p.is_dir():  # dir\n                    f += glob.glob(str(p / \"**\" / \"*.*\"), recursive=True)\n                    # f = list(p.rglob('*.*'))  # pathlib\n                elif p.is_file():  # file\n                    with open(p) as t:\n                        t = t.read().strip().splitlines()\n                        parent = str(p.parent) + os.sep\n                        f += [x.replace(\"./\", parent, 1) if x.startswith(\"./\") else x for x in t]  # to global path\n                        # f += [p.parent / x.lstrip(os.sep) for x in t]  # to global path (pathlib)\n                else:\n                    raise FileNotFoundError(f\"{prefix}{p} does not exist\")\n            self.im_files = sorted(x.replace(\"/\", os.sep) for x in f if x.split(\".\")[-1].lower() in IMG_FORMATS)\n            # self.img_files = sorted([x for x in f if x.suffix[1:].lower() in IMG_FORMATS])  # pathlib\n            assert self.im_files, f\"{prefix}No images found\"\n        except Exception as e:\n            raise RuntimeError(f\"{prefix}Error loading data from {path}: {e}\\n{HELP_URL}\") from e\n\n        # Check cache\n        self.label_files = img2label_paths(self.im_files)  # labels\n        cache_path = (p if p.is_file() else Path(self.label_files[0]).parent).with_suffix(\".cache\")\n        try:\n            cache, exists = np.load(cache_path, allow_pickle=True).item(), True  # load dict\n            assert cache[\"version\"] == self.cache_version  # matches current version\n            assert cache[\"hash\"] == get_hash(self.label_files + self.im_files)  # identical hash\n        except Exception:\n            cache, exists = self.cache_labels(cache_path, prefix), False  # run cache ops\n\n        # Display cache\n        nf, nm, ne, nc, n = cache.pop(\"results\")  # found, missing, empty, corrupt, total\n        if exists and LOCAL_RANK in {-1, 0}:\n            d = f\"Scanning {cache_path}... {nf} images, {nm + ne} backgrounds, {nc} corrupt\"\n            LOGGER.info(prefix + d)  # display cache results\n            if cache[\"msgs\"]:\n                LOGGER.info(\"\\n\".join(cache[\"msgs\"]))  # display warnings","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/ultralytics/yolov5/blob/20d1d78a08277e365d57bfa3a2cce752772d9e59/utils/dataloaders.py#L506-L542","documentation":"LoadImages wraps any exception during path scanning — including the FileNotFoundError of error [15] and the 'No images found' assert — into a RuntimeError that appends the YOLOv5 dataset HELP_URL. It is the single failure surface for 'your data yaml points at nothing usable': the inner message {e} names the concrete problem (missing path, zero images after filtering, unreadable txt) while the wrapper adds remediation docs.","triggerScenarios":"train.py/val.py with a data yaml whose train/val paths do not exist (inner [15] fires); a directory that exists but contains no files with image extensions (assert 'No images found'); a .txt manifest with zero valid lines; permission errors opening the txt file.","commonSituations":"Fresh clones without datasets; renamed dataset roots; yaml files copied between projects whose relative bases differ; uppercase extensions are handled, but unsupported formats (e.g. .jpeg2000) are filtered to zero.","solutions":["Read the inner exception text: '{prefix}{p} does not exist' means fix the path; 'No images found' means fix the file extensions/locations.","Download or relink the dataset so the yaml train/val paths exist (they resolve relative to the yaml's directory).","Confirm the directory actually contains supported extensions (jpg/png/bmp...).","Consult the HELP_URL printed in the message for dataset layout documentation."],"exampleFix":"# before\npython train.py --data mydata.yaml ...  # val path missing -> RuntimeError('Error loading data from ...')\n\n# after\n# create/point val correctly, e.g. download: https://... and rerun so autodownload fills DATASETS_DIR\npython train.py --data mydata.yaml ...","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\nimport yaml\n\ndef yaml_targets_resolve(data_yaml: str) -> bool:\n    p = Path(data_yaml).resolve()\n    d = yaml.safe_load(p.read_text())\n    base = Path(d.get('path') or p.parent)\n    ok = True\n    for key in ('train', 'val', 'test'):\n        v = d.get(key)\n        if not v:\n            continue\n        for x in (v if isinstance(v, list) else [v]):\n            target = Path(x) if str(x).startswith('/') else base / x\n            ok &= target.exists()\n    return ok","typeGuard":null,"tryCatchPattern":"try:\n    dataset = LoadImages(img_path, imgsz, ...)\nexcept RuntimeError as e:\n    if 'Error loading data from' in str(e):\n        # inner exception names the dead path; check yaml paths and dataset presence\n        raise SystemExit(f'fix data yaml paths: {e}') from e","preventionTips":["Treat the inner message as the actionable one; the wrapper only adds docs.","Add a preflight assert on im_files count > 0 in training scripts."],"tags":["dataloaders","dataset","training","error-wrapping"],"backgroundTag":null,"analyzedSha":"20d1d78a08277e365d57bfa3a2cce752772d9e59","analyzedAt":"2026-08-15T02:56:15.443Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}