xtekky/gpt4free · error · RuntimeError

Error: {msg}

Error message

Error: {msg}

What it means

Termux clang was invoked as `clang <src> -o pyandroid -I <home>/include/python3.14 -L <home>/lib -Wl,-rpath,<lib> -lpython3.14 -ldl` and returned non-zero. The child's stdout/stderr are wired to the parent's stderr, so the actual compiler diagnostic is already printed above this error; typical causes are missing headers/libs from an incomplete python merge or a broken Termux toolchain.

Source

Thrown at g4f/Provider/Copilot.py:413

                    yield msg.get("text")
                elif msg.get("event") == "titleUpdate":
                    yield TitleGeneration(msg.get("title"))
                elif msg.get("event") == "citation":
                    sources[msg.get("url")] = msg
                    yield SourceLink(
                        list(sources.keys()).index(msg.get("url")), msg.get("url")
                    )
                elif msg.get("event") == "partialImageGenerated":
                    mime_type = is_accepted_format(
                        base64.b64decode(msg.get("content")[:12])
                    )
                    yield ImagePreview(
                        f"data:{mime_type};base64,{msg.get('content')}", image_prompt
                    )
                elif msg.get("event") == "chainOfThought":
                    yield Reasoning(msg.get("text"))
                elif msg.get("event") == "error":
                    raise RuntimeError(f"Error: {msg}")
                elif msg.get("event") not in [
                    "received",
                    "startMessage",
                    "partCompleted",
                    "connected",
                ]:
                    debug.log(f"Copilot Message: {msg_txt[:100]}...")
            if not done:
                raise MissingAuthError(f"Invalid response: {last_msg}")
            if return_conversation:
                yield conversation
            if sources:
                yield Sources(sources.values())
            if not wss.closed:
                await wss.close()


async def get_access_token_and_cookies(

View on GitHub (pinned to 973504e177)

Solutions

  1. Read the clang diagnostic on stderr directly above this error — fatal error: Python.h: No such file means headers are missing, cannot find -lpython3.14 means the lib is missing
  2. Verify <binDir>/python-home/include/python3.14/Python.h and <binDir>/python-home/lib/libpython3.14.so exist; if not, wipe python-home and re-download a runtime flavor that ships dev files
  3. Ensure Termux's clang is installed: pkg install clang inside Termux (the hardcoded /data/data/com.termux/files/usr/bin/clang path must exist)
  4. Free disk space and retry if clang failed at the write-out stage
  5. Re-run the build manually with the same args printed in the source to iterate faster: clang <binDir>/pyandroid_runner.c -o <binDir>/pyandroid -I ... -L ... -Wl,-rpath,... -lpython3.14 -ldl
Defensive patterns

Strategy: validation

Validate before calling

home := androidPythonHome(binDir)
for _, p := range []string{
    filepath.Join(home, "include", "python3.14", "Python.h"),
    filepath.Join(home, "lib", "libpython3.14.so"),
    filepath.Join(binDir, "pyandroid_runner.c"),
} {
    if _, err := os.Stat(p); err != nil {
        return fmt.Errorf("runner build prerequisite missing: %s", p)
    }
}

Try / catch

if err := cmd.Run(); err != nil {
    // clang diagnostics already went to stderr; wrap with the invocation for reproducibility
    return fmt.Errorf("clang build of pyandroid runner failed (%s %v): %w", cc, args, err)
}

Prevention

When it happens

Trigger: home/include/python3.14 missing (runtime merged without dev files); libpython3.14.so absent from home/lib so the link fails; Termux clang not installed (only the fallback 'clang' on PATH was tried and is absent — though that fails at exec, surfacing differently); API-level/ABI mismatch between clang and the downloaded python build.

Common situations: Downloading a runtime flavor without include/ (install-only pbs builds strip headers); partial merge leaving lib/ incomplete; NDK/Termux toolchain version drift against python 3.14's built headers; disk full preventing the output binary from being written.

Related errors


AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14). Data as JSON: /api/errors/4c61d8e3b26f4720. Report an issue: GitHub.