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

Raised when the app path is treated as a plain file path (no colon notation) and, after resolving relative paths against the current working directory, the file does not exist on disk.

Source

Thrown at openbb_platform/extensions/platform_api/openbb_platform_api/utils/api.py:272

                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. Run the command from the directory containing the app file.
  2. Pass an absolute path to --app.
  3. Double-check spelling/case of the filename (case-sensitive on Linux).
  4. If the app lives in a package, switch to module notation 'pkg.module:app' after installing the package.

Example fix

# before
import_app('main.py', 'app')  # cwd has no main.py

# after
import_app(str(Path(__file__).parent / 'main.py'), 'app')
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
p = Path(app_path)
if not p.is_absolute():
    p = Path.cwd() / p
assert p.is_file(), f"app file not found: {p.resolve()}"

Type guard

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

Try / catch

try:
    app = import_app(app_path, name)
except FileNotFoundError:
    raise SystemExit(f"app file missing: {app_path}; run from project root or pass absolute path")

Prevention

When it happens

Trigger: Calling import_app('main.py', 'app') (or 'my_app/main.py') when no such file exists relative to CWD or as an absolute path.

Common situations: Starting the OpenBB API from the wrong directory; typos in the filename; the file was renamed or deleted; shell relative-path assumptions differing from Path.cwd().

Related errors


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