pola-rs/polars · error · FileNotFoundError

no dynamic library found at path

Error message

no dynamic library found at path: {path}

What it means

Plugin resolution failure in _resolve_plugin_path: the given path is not itself a file and scanning its directory yields no file that looks like a shared/dynamic library, so register_plugin_function cannot load anything from that location. Usually a wrong path or a directory without the compiled .so/.dylib/.dll.

Solutions

  1. Build the plugin first (cargo build --release) and point path at the built library or its directory
  2. Verify the path exists and contains a file with suffix .so, .dll, or .pyd
  3. Point directly at the .so file if you know its exact name

Example fix

// before
lf.register_plugin(path="myplugin/")  # empty dir
// after
lf.register_plugin(path="myplugin/target/release/libmyplugin.so")
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
p = Path(plugin_path)
if not (p.is_file() and p.suffix in ('.so', '.dll', '.pyd')) and not any(f.suffix in ('.so', '.dll', '.pyd') for f in p.iterdir()):
    raise FileNotFoundError(f"no dynamic library at {p}")

Try / catch

try:
    lf.register_plugin(path=plugin_path)
except FileNotFoundError:
    subprocess.run(["cargo", "build", "--release"], cwd=plugin_dir)

Prevention

When it happens

Trigger: Calling lf.register_plugin(path=...) with a directory containing no .so/.dll/.pyd files, or a wrong/typo'd path to a plugin binary.

Common situations: Rust plugin not compiled yet (cargo build not run); pointing at the source directory instead of target/release or target/debug; cross-platform extension mismatch.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/dc15144c41b9ec29. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/plugins.py:137

    # https://docs.rs/serde-pickle/latest/serde_pickle/
    return pickle.dumps(kwargs, protocol=5)


@lru_cache(maxsize=16)
def _resolve_plugin_path(path: Path | str, *, use_abs_path: bool = False) -> Path:
    """Get the file path of the dynamic library file."""
    if not isinstance(path, Path):
        path = Path(path)

    if path.is_file():
        return _resolve_file_path(path, use_abs_path=use_abs_path)

    for p in path.iterdir():
        if _is_dynamic_lib(p):
            return _resolve_file_path(p, use_abs_path=use_abs_path)

    msg = f"no dynamic library found at path: {path}"
    raise FileNotFoundError(msg)


def _is_dynamic_lib(path: Path) -> bool:
    return path.is_file() and path.suffix in (".so", ".dll", ".pyd")


def _resolve_file_path(path: Path, *, use_abs_path: bool = False) -> Path:
    venv_path = Path(sys.prefix)

    if use_abs_path:
        return path.resolve()
    else:
        try:
            file_path = path.relative_to(venv_path)
        except ValueError:  # Fallback
            file_path = path.resolve()

    return file_path

View on GitHub (pinned to fe841f959e)