MiniMax-AI/skills · error · FileNotFoundError

File not found: {file_path}

Error message

File not found: {file_path}

What it means

detect_and_load() checks path.exists() after the pandas import and raises FileNotFoundError with the given path. It is caught in main() and reported as exit code 1.

Source

Thrown at skills/minimax-xlsx/scripts/xlsx_reader.py:46

# ---------------------------------------------------------------------------

def detect_and_load(file_path: str, sheet_name_filter: str | None = None) -> dict:
    """
    Load file into {sheet_name: DataFrame} dict.
    CSV/TSV files are mapped to a single-key dict using the file stem as key.

    Raises ValueError for unsupported formats or encoding failures.
    """
    try:
        import pandas as pd
    except ImportError:
        raise RuntimeError(
            "pandas is not installed. Run: pip install pandas openpyxl"
        )

    path = Path(file_path)
    if not path.exists():
        raise FileNotFoundError(f"File not found: {file_path}")

    suffix = path.suffix.lower()

    if suffix in (".xlsx", ".xlsm"):
        target = sheet_name_filter if sheet_name_filter else None
        result = pd.read_excel(file_path, sheet_name=target)
        # pd.read_excel with sheet_name=None returns dict; with a name, returns DataFrame
        if isinstance(result, dict):
            return result
        else:
            return {sheet_name_filter: result}

    elif suffix in (".csv", ".tsv"):
        sep = "\t" if suffix == ".tsv" else ","
        encodings = ["utf-8-sig", "gbk", "utf-8", "latin-1"]
        last_error = None
        for enc in encodings:
            try:

View on GitHub (pinned to 60aaae52bb)

Solutions

  1. Verify the path exists: ls -la <file>
  2. Use an absolute path.
  3. Check spelling and case exactly (Linux is case-sensitive).

Example fix

# before
python3 xlsx_reader.py data.xlsx   # FileNotFoundError

# after
python3 xlsx_reader.py /abs/path/to/data.xlsx
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
if not Path(file_path).is_file():
    raise FileNotFoundError(f'File not found: {file_path}')

Type guard

def is_readable_file(p) -> bool:
    from pathlib import Path
    pp = Path(p)
    return pp.is_file() and os.access(pp, os.R_OK)

Try / catch

try:
    sheets = detect_and_load(file_path)
except FileNotFoundError as e:
    print(f'ERROR: {e}', file=sys.stderr)
    sys.exit(1)

Prevention

When it happens

Trigger: Passing a path that does not exist on disk — typo, relative path from the wrong working directory, or a file that was not yet downloaded/created.

Common situations: Wrong working directory; case-sensitivity mismatch on Linux; path with a trailing space or stray quote; file deleted/moved between runs.

Related errors


AI-assisted analysis of MiniMax-AI/skills@60aaae52bb (2026-08-13). Data as JSON: /api/errors/ff4a24431bfdc966. Report an issue: GitHub.