PaddlePaddle/PaddleOCR · error · ValueError
File not found: '{file_path}'
Error message
File not found: '{file_path}' What it means
ValueError from PaddleOCRVLLoader's lazy loading when a non-URL file_path does not exist on the local filesystem. The loader first checks _is_url; for local inputs it verifies Path(file_path).exists() before calling client.parse_document, raising with the exact path in the message.
Source
Thrown at langchain-paddleocr/langchain_paddleocr/document_loaders/paddleocr_vl.py:215
def _process_file(self, file_path: str) -> tuple[str, dict[str, Any]]:
"""Process a single file through the SDK and return text + raw result."""
with PaddleOCRClient(
token=self._token,
base_url=self._base_url,
client_platform="langchain",
poll_timeout=self._timeout,
) as client:
parse_kwargs: dict[str, Any] = {"options": self._options}
if self._model is not None:
parse_kwargs["model"] = self._model
if self._is_url(file_path):
result = client.parse_document(file_url=file_path, **parse_kwargs)
else:
local_path = Path(file_path)
if not local_path.exists():
msg = f"File not found: '{file_path}'"
raise ValueError(msg)
result = client.parse_document(
file_path=str(local_path),
**parse_kwargs,
)
text_parts = [page.markdown_text for page in result.pages if page.markdown_text]
text = _PAGES_DELIMITER.join(text_parts)
raw_response = {
"job_id": result.job_id,
"data_info": result.data_info,
"pages": [
{
"markdown_text": page.markdown_text,
"markdown_images": page.markdown_images,
"output_images": page.output_images,
"pruned_result": page.pruned_result,
"input_image_url": page.input_image_url,View on GitHub (pinned to 2661c7c0ef)
Solutions
- Pass an absolute path: `str(Path(file_path).resolve())`.
- Verify the file exists before constructing the load call (os.path.isfile).
- For remote files, use an http(s) URL so _is_url routes it to parse_document(file_url=...), or download it locally first.
Example fix
// before
loader = PaddleOCRVLLoader("data/report.pdf")
docs = loader.load() # ValueError if cwd != project root
// after
from pathlib import Path
loader = PaddleOCRVLLoader(str(Path("data/report.pdf").resolve()))
docs = loader.load() Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
import urllib.parse as _u
def is_http_url(s: str) -> bool:
p = _u.urlparse(s)
return p.scheme in ("http", "https") and bool(p.netloc)
def loader_input_ok(file_path: str) -> bool:
return is_http_url(file_path) or Path(file_path).is_file() Type guard
def is_loadable_source(src: object) -> bool:
"""True for http(s) URLs or existing local files."""
if not isinstance(src, str):
return False
p = urlparse(src)
if p.scheme in ("http", "https") and p.netloc:
return True
return Path(src).is_file() Try / catch
try:
docs = PaddleOCRVLLoader(path).load()
except ValueError as e:
if "File not found" in str(e):
path = str(Path(path).resolve()) # or download from remote storage first
docs = PaddleOCRVLLoader(path).load()
else:
raise Prevention
- Resolve paths to absolute before passing to the loader.
- Use http(s) URLs for remote documents; download cloud-storage objects locally first.
- In agents/notebooks, assert the file exists in the cell before the (lazy) load call.
When it happens
Trigger: Passing a relative path resolved from a different working directory; a typo'd or moved file; a remote-looking path (e.g. s3:// or ftp://) that fails the http(s) URL check and is then treated as local.
Common situations: Notebooks/agents running with a different cwd than expected; file already consumed/moved by a prior step; passing cloud-storage URIs unsupported by the loader.
Related errors
- Unsupported model: {model!r}
- {file_path}
- fileUrl and filePath are mutually exclusive.
- Environment Variable CUDA_VISIBLE_DEVICES is not set correct
- The input data is inconsistent with expectations.
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/930b2f12f7b548f0.
Report an issue: GitHub.