xtekky/gpt4free · error · MissingRequirementsError

Install "gpt4all" package | pip install -U g4f[local]

Error message

Install "gpt4all" package | pip install -U g4f[local]

What it means

MissingRequirementsError from the local GPT4All provider: the optional gpt4all package (via ...locals.provider → LocalProvider) failed to import at module load, so has_requirements is False and create_completion refuses to run. This is g4f's standard pattern for optional heavy dependencies — the error message contains the exact pip extra to install.

Source

Thrown at g4f/Provider/local/Local.py:37

    working = has_requirements
    active_by_default = False
    supports_message_history = True
    supports_system_message = True
    supports_stream = True

    @classmethod
    def get_models(cls):
        if not cls.models:
            cls.models = list(get_models())
            cls.default_model = cls.models[0]
        return cls.models

    @classmethod
    def create_completion(
        cls, model: str, messages: Messages, stream: bool, **kwargs
    ) -> CreateResult:
        if not has_requirements:
            raise MissingRequirementsError(
                'Install "gpt4all" package | pip install -U g4f[local]'
            )
        return LocalProvider.create_completion(
            cls.get_model(model), messages, stream, **kwargs
        )

View on GitHub (pinned to 973504e177)

Solutions

  1. Install the extra exactly as the message says: pip install -U "g4f[local]".
  2. If it still fails, reinstall cleanly: pip uninstall gpt4all g4f && pip install -U "g4f[local]".
  3. On Linux containers, ensure gpt4all's native runtime libs (libc, libgomp) are present.
  4. If you never intended local inference, stop routing requests to the Local provider (pick a remote provider or set the model explicitly).

Example fix

# before
pip install g4f

# after
pip install -U "g4f[local]"
Defensive patterns

Strategy: validation

Validate before calling

from g4f.Provider.local.Local import has_requirements
if not has_requirements:
    raise SystemExit('Run: pip install -U "g4f[local]"')

Type guard

def local_ready() -> bool:
    from g4f.Provider.local.Local import has_requirements
    return has_requirements

Try / catch

try:
    ...
except MissingRequirementsError as e:
    print(f'Install missing extras: {e}')  # message contains the exact pip command
    raise

Prevention

When it happens

Trigger: Calling Local.create_completion (or routing a request to the 'Local'/'GPT4All' provider) in an environment where g4f was installed without the [local] extra, so gpt4all is absent; a broken gpt4all install that raises ImportError on import (missing native libs); or gpt4all installed but its version incompatible with the wrapper module.

Common situations: pip install g4f instead of g4f[local]; virtualenv recreated without extras; deploying to slim Docker images lacking gpt4all's native dependencies; gpt4all version drift after a g4f upgrade changed the expected API.

Related errors


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