microsoft/qlib · error · OSError

Network path not found

Error message

Network path not found

What it means

Raised by DumpDataBase._dump_bin (scripts/dump_bin.py:284) when the file_or_data argument is neither a pandas DataFrame (with rows) nor a pathlib.Path. The method dispatches on type: DataFrames are normalized via fname_to_code on the symbol field, Paths are read through _get_source_data/get_symbol_from_file; anything else (str, list, None, numpy array, etc.) is unsupported. Note it requires pathlib.Path specifically — a plain string path will hit this branch even though it looks like a path.

Source

Thrown at qlib/__init__.py:121

    else:
        # Judging system type
        sys_type = platform.system()
        if "windows" in sys_type.lower():
            # system: window
            try:
                subprocess.run(
                    ["mount", "-o", "anon", provider_uri, mount_path],
                    capture_output=True,
                    text=True,
                    check=True,
                )
                LOG.info("Mount finished.")
            except subprocess.CalledProcessError as e:
                error_output = (e.stdout or "") + (e.stderr or "")
                if e.returncode == 85:
                    LOG.warning(f"{provider_uri} already mounted at {mount_path}")
                elif e.returncode == 53:
                    raise OSError("Network path not found") from e
                elif "error" in error_output.lower() or "错误" in error_output:
                    raise OSError("Invalid mount path") from e
                else:
                    raise OSError(f"Unknown mount error: {error_output.strip()}") from e
        else:
            # system: linux/Unix/Mac
            # check mount
            _remote_uri = provider_uri[:-1] if provider_uri.endswith("/") else provider_uri
            # `mount a /b/c` is different from `mount a /b/c/`. So we convert it into string to make sure handling it accurately
            mount_path = str(mount_path)
            _mount_path = mount_path[:-1] if mount_path.endswith("/") else mount_path
            _check_level_num = 2
            _is_mount = False
            while _check_level_num:
                with subprocess.Popen(
                    ["mount"],
                    text=True,
                    stdout=subprocess.PIPE,

View on GitHub (pinned to 79633dd950)

Solutions

  1. Wrap string paths in pathlib.Path: _dump_bin(Path(file_path), calendar_list).
  2. Convert non-DataFrame data before calling: pd.DataFrame(rows) for dicts/lists; build a proper DataFrame with symbol_field_name and date_field_name columns for numpy arrays.
  3. If subclassing, keep the contract: override _get_source_data (Path -> DataFrame) rather than bypassing _dump_bin's expected input types.

Example fix

# before
for name in os.listdir(data_dir):
    dumper._dump_bin(os.path.join(data_dir, name), calendar_list)  # str -> ValueError: not support <class 'str'>

# after
from pathlib import Path
for p in Path(data_dir).iterdir():
    if p.is_file():
        dumper._dump_bin(p, calendar_list)
Defensive patterns

Strategy: type-guard

Validate before calling

from pathlib import Path
import pandas as pd
assert isinstance(file_or_data, (pd.DataFrame, Path)), f"expected DataFrame or Path, got {type(file_or_data)}"

Type guard

from pathlib import Path
import pandas as pd

def is_dump_input(obj) -> bool:
    return isinstance(obj, (pd.DataFrame, Path))

Try / catch

try:
    dumper._dump_bin(file_or_data, calendar_list)
except ValueError as e:
    if "not support" in str(e):
        if isinstance(file_or_data, str):
            dumper._dump_bin(Path(file_or_data), calendar_list)  # recover from str paths
        else:
            raise
    else:
        raise

Prevention

When it happens

Trigger: Calling dump_bin / _dump_bin with a string filename instead of Path(filename); passing a numpy structured array, dict, or list of dicts instead of a DataFrame; subclassing DumpDataBase and overriding the data source to feed an incompatible type; passing None when upstream code fails to load data.

Common situations: Callers building file paths with os.path.join or f-strings (which yield str) and forgetting to wrap in Path(); glue code that iterates os.listdir (str names) instead of Path.iterdir(); custom normalizers returning raw numpy arrays or tuples from a load step.

Related errors


AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15). Data as JSON: /api/errors/92e334c86a773c93. Report an issue: GitHub.