OpenBB-finance/OpenBB · error · FileNotFoundError

Error: The app file '{app_path}' does not exist

Error message

Error: The app file '{app_path}' does not exist

What it means

FileNotFoundError raised when the --app argument looks like a plain file path (no colon notation) and that file does not exist after resolving relative paths against the current working directory. This is the file-path branch of the app importer, as opposed to the module branch of error 128.

Source

Thrown at openbb_platform/extensions/mcp_server/openbb_mcp_server/utils/app_import.py:69

                file_path = str(cwd.joinpath(module_path).resolve())
            else:
                file_path = module_path

            if not Path(file_path).exists():
                raise FileNotFoundError(  # pylint: disable=raise-missing-from
                    f"Error: Neither module '{module_path}' could be imported nor file '{file_path}' exists"
                )

            module = _load_module_from_file_path(file_path)

    # Case 2: File path (e.g., "main.py" or "my_app/main.py")
    else:
        if not Path(app_path).is_absolute():
            cwd = Path.cwd()
            app_path = str(cwd.joinpath(app_path).resolve())

        if not Path(app_path).exists():
            raise FileNotFoundError(f"Error: The app file '{app_path}' does not exist")

        module = _load_module_from_file_path(app_path)

    if not hasattr(module, name):
        raise AttributeError(
            f"Error: The app file '{app_path}' does not contain an '{name}' instance"
        )

    app_or_factory = getattr(module, name)

    # Here we use the same approach as uvicorn to handle factory functions.
    # This prevents us from relying on explicit type annotations.
    # See: https://github.com/encode/uvicorn/blob/master/uvicorn/config.py
    try:
        app = app_or_factory()
        if not factory:
            print(  # noqa: T201
                "\n\n[WARNING]   "

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Use an absolute path: --app /opt/myapp/main.py
  2. Or cd into the directory containing the file before launching
  3. Verify with ls or Path('--app value').exists() that the resolved path is real

Example fix

# before
openbb-mcp --app ./some_app.py   # launched from a different cwd

# after
openbb-mcp --app /abs/path/to/some_app.py
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

p = Path(app_path)
resolved = p if p.is_absolute() else (Path.cwd() / p).resolve()
if not resolved.exists():
    raise ValueError(f"app file not found at resolved path: {resolved}")

Type guard

def app_file_exists(app_path: str) -> bool:
    p = Path(app_path)
    resolved = p if p.is_absolute() else (Path.cwd() / p).resolve()
    return resolved.is_file()

Try / catch

try:
    app = import_app(app_path, "app")
except FileNotFoundError as e:
    if "does not exist" in str(e):
        app = import_app(str(PROJECT_ROOT / "main.py"), "app")  # known-good absolute path
    else:
        raise

Prevention

When it happens

Trigger: --app ./some_app.py when some_app.py is not in the CWD; the path is resolved with Path.cwd().joinpath(...).resolve() first, so any relative path is interpreted relative to where the command was launched, not the config file or package root.

Common situations: Launching the server via a service manager (systemd, Docker) whose working directory differs from the developer's shell, typos in the filename, moving/renaming the app file without updating the command, trailing spaces in the path.

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/998d83abd34b26d0. Report an issue: GitHub.