deepinsight/insightface · error · LookupError

Unknown calling convention '{}' for function '{}'

Error message

Unknown calling convention '{}' for function '{}'

What it means

Thrown by LibraryLoader.Lookup.get() when the requested ctypes calling convention key is not present in the loader's access dict. The loader is constructed with cdecl only (ctypes.CDLL), so asking for any other convention (e.g. 'stdcall') raises this LookupError before the symbol is fetched.

Source

Thrown at cpp-package/inspireface/python/inspireface/modules/core/native.py:600

    Subclasses load libraries for specific platforms.
    """

    # library names formatted specifically for platforms
    name_formats = ["%s"]

    class Lookup:
        """Looking up calling conventions for a platform"""

        mode = ctypes.DEFAULT_MODE

        def __init__(self, path):
            super(LibraryLoader.Lookup, self).__init__()
            self.access = dict(cdecl=ctypes.CDLL(path, self.mode))

        def get(self, name, calling_convention="cdecl"):
            """Return the given name according to the selected calling convention"""
            if calling_convention not in self.access:
                raise LookupError(
                    "Unknown calling convention '{}' for function '{}'".format(
                        calling_convention, name
                    )
                )
            return getattr(self.access[calling_convention], name)

        def has(self, name, calling_convention="cdecl"):
            """Return True if this given calling convention finds the given 'name'"""
            if calling_convention not in self.access:
                return False
            return hasattr(self.access[calling_convention], name)

        def __getattr__(self, name):
            return getattr(self.access["cdecl"], name)

    def __init__(self):
        self.other_dirs = []

View on GitHub (pinned to 7fadd420c2)

Solutions

  1. Use the default: call get(name) or pass calling_convention='cdecl'
  2. If you truly need stdcall on Windows, construct the loader with a stdcall entry (ctypes.WinDLL) so the key exists in access
  3. Update your loader snippet to the current InspireFace API which is cdecl-only

Example fix

# before
func = loader.get('HFCreateInspireFaceSession', 'stdcall')
# after
func = loader.get('HFCreateInspireFaceSession', 'cdecl')
# or simply the default
func = loader.get('HFCreateInspireFaceSession')
Defensive patterns

Strategy: type-guard

Type guard

def valid_convention(c: str) -> bool:
    return c == 'cdecl'

Try / catch

try:
    fn = loader.get(name, cc)
except LookupError:
    fn = loader.get(name)  # fall back to cdecl

Prevention

When it happens

Trigger: Calling loader.get(func_name, calling_convention='stdcall') or any convention other than 'cdecl' on the InspireFace library loader. Only happens in custom/low-level code that drives the ctypes loader directly rather than through the wrapped API functions.

Common situations: Porting Windows-era ctypes code that used WinDLL/stdcall; copy-pasting a generic ctypes loader snippet with a convention parameter; library version changes that removed non-cdecl loaders.

Related errors


AI-assisted analysis of deepinsight/insightface@7fadd420c2 (2026-08-28). Data as JSON: /api/errors/a774b12aed1b3b15. Report an issue: GitHub.