{"record":{"id":"598fe7a4b1688e51","repo":"NaiboWang/EasySpider","slug":"file-does-not-exist-s","errorCode":null,"errorMessage":"file does not exist: %s","messagePattern":"file does not exist: (.+?)","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"error","filePath":"ExecuteStage/undetected_chromedriver_ES/patcher.py","lineNumber":195,"sourceCode":"        self.version_full = release\n        self.unzip_package(self.fetch_package())\n        return self.patch()\n\n    def driver_binary_in_use(self, path: str = None) -> bool:\n        \"\"\"\n        naive test to check if a found chromedriver binary is\n        currently in use\n\n        Args:\n            path: a string or PathLike object to the binary to check.\n                  if not specified, we check use this object's executable_path\n        \"\"\"\n        if not path:\n            path = self.executable_path\n        p = pathlib.Path(path)\n\n        if not p.exists():\n            raise OSError(\"file does not exist: %s\" % p)\n        try:\n            with open(p, mode=\"a+b\") as fs:\n                exc = []\n                try:\n\n                    fs.seek(0, 0)\n                except PermissionError as e:\n                    exc.append(e)  # since some systems apprently allow seeking\n                    # we conduct another test\n                try:\n                    fs.readline()\n                except PermissionError as e:\n                    exc.append(e)\n\n                if exc:\n\n                    return True\n                return False","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/NaiboWang/EasySpider/blob/191bd6d7547bb397e4c579dd2c70ae835be3f512/ExecuteStage/undetected_chromedriver_ES/patcher.py#L177-L213","documentation":"Raised as OSError by Patcher.driver_binary_in_use (ExecuteStage/undetected_chromedriver_ES/patcher.py:195) when the chromedriver binary path - either the argument `path` or self.executable_path - does not exist on disk. It is a precondition check before testing whether the binary is locked/in use.","triggerScenarios":"Calling driver_binary_in_use(path) (or driver_binary_in_use() which falls back to self.executable_path) when pathlib.Path(path).exists() is False raises OSError(f'file does not exist: %s' % p).","commonSituations":"First run before patcher.auto() has downloaded chromedriver; a custom driver_executable_path that points nowhere; the data_path was cleaned (temp deletion, Docker layer reset); a failed/incomplete download left no binary; version_main mismatch caused auto() to skip download.","solutions":["Ensure patcher.auto() has completed (it downloads + patches chromedriver) before calling driver_binary_in_use.","If you pass driver_executable_path to Patcher/Chrome, verify the file exists before constructing the driver.","Do not override executable_path unless you manage the binary yourself; let the patcher place it in data_path.","Check read/execute permissions on the data_path directory (~/.local/share/undetected_chromedriver on Linux)."],"exampleFix":"# before\nfrom patcher import Patcher\np = Patcher(executable_path='/custom/chromedriver')\np.driver_binary_in_use()  # throws if missing\n\n# after - let auto() fetch it, then check\nfrom patcher import Patcher\nimport pathlib\np = Patcher()  # automatic path\nif not pathlib.Path(p.executable_path).exists():\n    p.auto()  # download + patch\nassert p.driver_binary_in_use() is not None","handlingStrategy":"validation","validationCode":"import pathlib, os\ndef chromedriver_ready(executable_path: str) -> bool:\n    p = pathlib.Path(executable_path)\n    return p.exists() and os.access(str(p), os.X_OK)\n\nif not chromedriver_ready(p.executable_path):\n    p.auto()  # ensure binary exists before driver_binary_in_use()","typeGuard":null,"tryCatchPattern":"import pathlib\ntry:\n    in_use = patcher.driver_binary_in_use()\nexcept OSError as e:\n    if 'file does not exist' in str(e):\n        patcher.auto()  # download then retry\n        in_use = patcher.driver_binary_in_use()\n    else:\n        raise","preventionTips":["Call patcher.auto() once at startup; it is idempotent and ensures the binary exists.","In CI/containers, persist the data_path across runs or pre-download chromedriver so first-run races do not occur.","Never hard-code an executable_path you have not validated with pathlib.Path(...).exists()."],"tags":["undetected-chromedriver","chromedriver","file-not-found","configuration","python"],"backgroundTag":null,"analyzedSha":"191bd6d7547bb397e4c579dd2c70ae835be3f512","analyzedAt":"2026-08-13T03:11:17.041Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}