{"record":{"id":"eced04e89408ec92","repo":"ultralytics/yolov5","slug":"prefix-p-does-not-exist","errorCode":null,"errorMessage":"{prefix}{p} does not exist","messagePattern":"(.+?)(.+?) does not exist","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"utils/dataloaders.py","lineNumber":519,"sourceCode":"        self.stride = stride\n        self.path = path\n        self.albumentations = Albumentations(size=img_size) if augment else None\n\n        try:\n            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","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/ultralytics/yolov5/blob/20d1d78a08277e365d57bfa3a2cce752772d9e59/utils/dataloaders.py#L501-L537","documentation":"LoadImages (utils/dataloaders.py) raises FileNotFoundError with a dataset prefix when a path entry from the data yaml / input list is neither an existing directory nor an existing file. This is the training/validation image-list builder: it accepts a directory, an image file, or a .txt listing images, and rejects anything else. The error is immediately re-wrapped by the except into the RuntimeError of error [16], so this message appears as the inner cause.","triggerScenarios":"data yaml 'train: ../coco/train2017.txt' when that txt is absent; 'val: /datasets/coco/val2017' directory not yet downloaded or moved; a txt list whose parent-relative entries resolve to nothing (this check is on the list file itself, not its contents); wrong relative base when the yaml lives elsewhere.","commonSituations":"First runs before the dataset is downloaded; datasets relocated after yaml creation; sharing yamls across machines with different mounts; paths written on Windows and run on Linux.","solutions":["Download the dataset first (let check_dataset autodownload via the yaml 'download:' field, or fetch manually).","Fix the yaml paths to actual locations — check them with Path(yaml_path).parent / train_path existence from the yaml's directory.","If the dataset is present, correct the relative base: paths in the yaml are resolved relative to the yaml file's parent."],"exampleFix":"# before (data.yaml):  val: /mnt/nfs/coco/val2017  # not mounted\n\n# after (data.yaml):   val: ../datasets/coco/val2017  # exists next to the yaml","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef dataset_paths_exist(data_yaml: str) -> bool:\n    import yaml\n    p = Path(data_yaml).resolve()\n    d = yaml.safe_load(p.read_text())\n    base = Path(d.get('path') or p.parent)\n    for key in ('train', 'val'):\n        entry = d.get(key)\n        if entry is None:\n            continue\n        for x in (entry if isinstance(entry, list) else [entry]):\n            if not (base / x if not str(x).startswith('/') else Path(x)).exists():\n                return False\n    return True","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run a path-existence check on data yaml entries before launching multi-hour training.","Keep datasets and yamls together so relative resolution stays stable."],"tags":["dataloaders","dataset","training","filesystem"],"backgroundTag":null,"analyzedSha":"20d1d78a08277e365d57bfa3a2cce752772d9e59","analyzedAt":"2026-08-15T02:56:15.443Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}