opendatalab/MinerU · error · FileNotFoundError
Input path does not exist: {path}
Error message
Input path does not exist: {path} What it means
Raised by collect_input_files() in demo/demo.py when the path passed as input_path does not exist on disk after expanduser().resolve(). This is a fail-fast precondition check before any file-type sniffing or parsing happens. The resolved absolute path is included in the message so the user can see exactly what MinerU looked for.
Source
Thrown at demo/demo.py:19
# Copyright (c) Opendatalab. All rights reserved.
import asyncio
import os
import tempfile
from pathlib import Path
import httpx
from mineru.cli import api_client as _api_client
from mineru.cli.common import image_suffixes, office_suffixes, pdf_suffixes
from mineru.utils.guess_suffix_or_lang import guess_suffix_by_path
SUPPORTED_INPUT_SUFFIXES = set(pdf_suffixes + image_suffixes + office_suffixes)
def collect_input_files(input_path: str | Path) -> list[Path]:
path = Path(input_path).expanduser().resolve()
if not path.exists():
raise FileNotFoundError(f"Input path does not exist: {path}")
if path.is_file():
file_suffix = guess_suffix_by_path(path)
if file_suffix not in SUPPORTED_INPUT_SUFFIXES:
raise ValueError(f"Unsupported input file type: {path.name}")
return [path]
if not path.is_dir():
raise ValueError(f"Input path must be a file or directory: {path}")
input_files = sorted(
(
candidate.resolve()
for candidate in path.iterdir()
if candidate.is_file()
and guess_suffix_by_path(candidate) in SUPPORTED_INPUT_SUFFIXES
),
key=lambda item: item.name,View on GitHub (pinned to 4fe4bde114)
Solutions
- Verify the path exists: ls -l <path> and confirm spelling.
- Use an absolute path, or resolve relative to a known anchor (e.g. Path(__file__).parent / 'inputs') before passing it.
- If the file is expected to be generated upstream, add a check/step that produces it before calling MinerU.
- In containers, confirm the volume mount actually exposes the file.
Example fix
// before
result = parse("~/data/repot.pdf")
// after
from pathlib import Path
p = Path("~/data/report.pdf").expanduser().resolve()
if not p.exists():
raise SystemExit(f"missing input: {p}")
result = parse(str(p)) Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
def ensure_input_exists(input_path: str) -> Path:
p = Path(input_path).expanduser().resolve()
if not p.exists():
raise SystemExit(f"input not found: {p}")
return p Type guard
from pathlib import Path
def is_existing_path(value: str) -> bool:
try:
return Path(value).expanduser().resolve().exists()
except OSError:
return False Try / catch
try:
files = collect_input_files(path)
except FileNotFoundError as e:
log.error("input missing: %s", e)
sys.exit(2) Prevention
- Always expanduser().resolve() paths at your own boundary before passing them.
- In scripts, anchor relative paths to Path(__file__).parent or an explicit CLI arg.
- Fail fast in CI: assert inputs exist before the parse stage.
When it happens
Trigger: Calling the demo entry point with input_path pointing at a missing file or directory (typo, wrong cwd, unexpanded '~' that resolves to nothing, or a path on another machine/container). Anything that makes Path(input_path).expanduser().resolve().exists() return False.
Common situations: Relative paths run from a different working directory; typos in CLI args; Docker containers where the file was not mounted; CI jobs where artifacts were not downloaded before invocation.
Related errors
- Input path must be a file or directory: {path}
- No supported files found in directory: {path}
- Unsupported input file type: {path.name}
- Unknown file suffix: {file_suffix}
- The provided path starts with '/'. This does not conform to
AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14).
Data as JSON: /api/errors/0c677f15c7bc19e3.
Report an issue: GitHub.