{"record":{"id":"a415e4395e7dfb15","repo":"ultralytics/yolov5","slug":"p-does-not-exist","errorCode":null,"errorMessage":"{p} does not exist","messagePattern":"(.+?) does not exist","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"utils/dataloaders.py","lineNumber":282,"sourceCode":"\nclass LoadImages:\n    \"\"\"YOLOv5 image/video dataloader, i.e. `python detect.py --source image.jpg/vid.mp4`.\"\"\"\n\n    def __init__(self, path, img_size=640, stride=32, auto=True, transforms=None, vid_stride=1):\n        \"\"\"Initializes YOLOv5 loader for images/videos, supporting glob patterns, directories, and lists of paths.\"\"\"\n        if isinstance(path, str) and Path(path).suffix == \".txt\":  # *.txt file with img/vid/dir on each line\n            path = Path(path).read_text().strip().splitlines()\n        files = []\n        for p in sorted(path) if isinstance(path, (list, tuple)) else [path]:\n            p = str(Path(p).resolve())\n            if \"*\" in p:\n                files.extend(sorted(glob.glob(p, recursive=True)))  # glob\n            elif os.path.isdir(p):\n                files.extend(sorted(glob.glob(os.path.join(p, \"*.*\"))))  # dir\n            elif os.path.isfile(p):\n                files.append(p)  # files\n            else:\n                raise FileNotFoundError(f\"{p} does not exist\")\n\n        images = [x for x in files if x.split(\".\")[-1].lower() in IMG_FORMATS]\n        videos = [x for x in files if x.split(\".\")[-1].lower() in VID_FORMATS]\n        ni, nv = len(images), len(videos)\n\n        self.img_size = img_size\n        self.stride = stride\n        self.files = images + videos\n        self.nf = ni + nv  # number of files\n        self.video_flag = [False] * ni + [True] * nv\n        self.mode = \"image\"\n        self.auto = auto\n        self.transforms = transforms  # optional\n        self.vid_stride = vid_stride  # video frame-rate stride\n        if any(videos):\n            self._new_video(videos[0])  # new video\n        else:\n            self.cap = None","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/ultralytics/yolov5/blob/20d1d78a08277e365d57bfa3a2cce752772d9e59/utils/dataloaders.py#L264-L300","documentation":"LoadImagesAndVideos (utils/dataloaders.py) raises FileNotFoundError when an entry of the source list/path is neither a glob pattern (contains '*'), nor a directory, nor a file after resolve(). This dataset class is used by detect.py/val.py for inference-time media loading; each item must be a literal existing path or a wildcard pattern.","triggerScenarios":"run(source='vids/demo.mp4') with a typo or wrong cwd; a .txt list containing one dead entry (every line is resolved individually); paths that contain no '*' but reference a missing mount; passing a URL without a recognized scheme so it is treated as a path.","commonSituations":"Relative paths resolved from a different working directory; txt manifests generated on another machine with absolute paths; NFS mounts not yet attached at job start.","solutions":["Print the resolved path from the same cwd to confirm: python -c \"from pathlib import Path; print(Path('src').resolve(), Path('src').exists())\".","Use absolute paths in source lists and .txt manifests.","Use a wildcard ('dir/*.jpg') so the glob branch handles missing matches instead of failing on existence.","Prune dead lines from txt manifests before running."],"exampleFix":"# before\ndataset = LoadImagesAndVideos('clips/day1.mp4')  # typo'd name\n\n# after\ndataset = LoadImagesAndVideos('/data/clips/day1.mp4')","handlingStrategy":"validation","validationCode":"from pathlib import Path\nimport glob as _glob\n\ndef sources_readable(path) -> bool:\n    if isinstance(path, str) and Path(path).suffix == '.txt':\n        path = Path(path).read_text().strip().splitlines()\n    items = sorted(path) if isinstance(path, (list, tuple)) else [path]\n    for p in items:\n        p = str(Path(p).resolve())\n        if '*' in p:\n            continue\n        if not (Path(p).is_dir() or Path(p).is_file()):\n            return False\n    return True","typeGuard":null,"tryCatchPattern":"try:\n    dataset = LoadImagesAndVideos(source)\nexcept FileNotFoundError as e:\n    raise SystemExit(f'missing inference source: {e}') from e","preventionTips":["Lint media manifests for dead entries before jobs.","Anchor source paths to a project ROOT constant."],"tags":["inference","dataloaders","filesystem","source-path"],"backgroundTag":null,"analyzedSha":"20d1d78a08277e365d57bfa3a2cce752772d9e59","analyzedAt":"2026-08-15T02:56:15.443Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}