NaiboWang/EasySpider · error · OSError

file does not exist: %s

Error message

file does not exist: %s

What it means

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.

Source

Thrown at ExecuteStage/undetected_chromedriver_ES/patcher.py:195

        self.version_full = release
        self.unzip_package(self.fetch_package())
        return self.patch()

    def driver_binary_in_use(self, path: str = None) -> bool:
        """
        naive test to check if a found chromedriver binary is
        currently in use

        Args:
            path: a string or PathLike object to the binary to check.
                  if not specified, we check use this object's executable_path
        """
        if not path:
            path = self.executable_path
        p = pathlib.Path(path)

        if not p.exists():
            raise OSError("file does not exist: %s" % p)
        try:
            with open(p, mode="a+b") as fs:
                exc = []
                try:

                    fs.seek(0, 0)
                except PermissionError as e:
                    exc.append(e)  # since some systems apprently allow seeking
                    # we conduct another test
                try:
                    fs.readline()
                except PermissionError as e:
                    exc.append(e)

                if exc:

                    return True
                return False

View on GitHub (pinned to 191bd6d754)

Solutions

  1. Ensure patcher.auto() has completed (it downloads + patches chromedriver) before calling driver_binary_in_use.
  2. If you pass driver_executable_path to Patcher/Chrome, verify the file exists before constructing the driver.
  3. Do not override executable_path unless you manage the binary yourself; let the patcher place it in data_path.
  4. Check read/execute permissions on the data_path directory (~/.local/share/undetected_chromedriver on Linux).

Example fix

# before
from patcher import Patcher
p = Patcher(executable_path='/custom/chromedriver')
p.driver_binary_in_use()  # throws if missing

# after - let auto() fetch it, then check
from patcher import Patcher
import pathlib
p = Patcher()  # automatic path
if not pathlib.Path(p.executable_path).exists():
    p.auto()  # download + patch
assert p.driver_binary_in_use() is not None
Defensive patterns

Strategy: validation

Validate before calling

import pathlib, os
def chromedriver_ready(executable_path: str) -> bool:
    p = pathlib.Path(executable_path)
    return p.exists() and os.access(str(p), os.X_OK)

if not chromedriver_ready(p.executable_path):
    p.auto()  # ensure binary exists before driver_binary_in_use()

Try / catch

import pathlib
try:
    in_use = patcher.driver_binary_in_use()
except OSError as e:
    if 'file does not exist' in str(e):
        patcher.auto()  # download then retry
        in_use = patcher.driver_binary_in_use()
    else:
        raise

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of NaiboWang/EasySpider@191bd6d754 (2026-08-13). Data as JSON: /api/errors/598fe7a4b1688e51. Report an issue: GitHub.