pypa/pip · error · SystemError

invalid sysconfig.get_config_var('EXT_SUFFIX')

Error message

invalid sysconfig.get_config_var('EXT_SUFFIX')

What it means

Raised by `_generic_abi()` in `packaging.tags` when `sysconfig.get_config_var('EXT_SUFFIX')` returns a value that is not a string or does not begin with a '.'. The EXT_SUFFIX encodes the CPython ABI (e.g. '.cpython-310-x86_64-linux-gnu.so'); if it is malformed, the library cannot infer the current interpreter's ABI tag and aborts with `SystemError`. This almost always indicates a broken or non-standard Python build/install rather than a packaging bug.

Source

Thrown at src/pip/_vendor/packaging/tags.py:421

def _generic_abi() -> list[str]:
    """
    Return the ABI tag based on EXT_SUFFIX.
    """
    # The following are examples of `EXT_SUFFIX`.
    # We want to keep the parts which are related to the ABI and remove the
    # parts which are related to the platform:
    # - linux:   '.cpython-310-x86_64-linux-gnu.so' => cp310
    # - mac:     '.cpython-310-darwin.so'           => cp310
    # - win:     '.cp310-win_amd64.pyd'             => cp310
    # - win:     '.pyd'                             => cp37 (uses _cpython_abis())
    # - pypy:    '.pypy38-pp73-x86_64-linux-gnu.so' => pypy38_pp73
    # - graalpy: '.graalpy-38-native-x86_64-darwin.dylib'
    #                                               => graalpy_38_native

    ext_suffix = _get_config_var("EXT_SUFFIX", warn=True)
    if not isinstance(ext_suffix, str) or ext_suffix[0] != ".":
        raise SystemError("invalid sysconfig.get_config_var('EXT_SUFFIX')")
    parts = ext_suffix.split(".")
    if len(parts) < 3:
        # CPython3.7 and earlier uses ".pyd" on Windows.
        return _cpython_abis(sys.version_info[:2])
    soabi = parts[1]
    if soabi.startswith("cpython"):
        # non-windows
        abi = "cp" + soabi.split("-")[1]
    elif soabi.startswith("cp"):
        # windows
        abi = soabi.split("-")[0]
    elif soabi.startswith("pypy"):
        abi = "-".join(soabi.split("-")[:2])
    elif soabi.startswith("graalpy"):
        abi = "-".join(soabi.split("-")[:3])
    elif soabi:
        # pyston, ironpython, others?
        abi = soabi

View on GitHub (pinned to d7d0d0a394)

Solutions

  1. Verify the value with `python -c "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))"` — it must be a string starting with '.'.
  2. Switch to a known-good interpreter (official CPython from python.org, an unmodified conda env, distro python3 package).
  3. If compiling CPython yourself, ensure EXT_SUFFIX is set (it derives from `ALT_SOABI`/`SOABI`/`EXT_SUFFIX` config); reconfigure and rebuild.
  4. If you cannot change interpreters, avoid the generic-ABI path by constructing `Tag` objects explicitly or calling an interpreter-specific tags function (e.g. `cpython_tags`) with explicit `abis=...`.
  5. Report the broken sysconfig to the maintainer of your Python distribution.

Example fix

// before
from pip._vendor.packaging.tags import sys_tags
tags = list(sys_tags())  # raises SystemError on broken EXT_SUFFIX

# after
import sysconfig
from pip._vendor.packaging.tags import cpython_tags
ext = sysconfig.get_config_var('EXT_SUFFIX')
if not isinstance(ext, str) or not ext.startswith('.'):
    # fall back to explicit interpreter/abi/platform
    tags = list(cpython_tags(abis=['cp311', 'abi3', 'none'],
                             platforms=['linux_x86_64']))
else:
    tags = list(sys_tags())
Defensive patterns

Strategy: try-catch

Validate before calling

import sysconfig

def has_valid_ext_suffix() -> bool:
    ext = sysconfig.get_config_var('EXT_SUFFIX')
    return isinstance(ext, str) and ext.startswith('.')

Try / catch

from pip._vendor.packaging import tags

try:
    abi = tags._generic_abi()
except SystemError:
    # broken interpreter sysconfig; supply explicit abis instead
    abi = ['cp311', 'abi3', 'none']

Prevention

When it happens

Trigger: Calling `tags._generic_abi()` directly, or indirectly via `tags.sys_tags()` / `tags.generic_tags()` / `pip`-style wheel compatibility resolution, on an interpreter where `sysconfig.get_config_var('EXT_SUFFIX')` returns `None`, a non-string, or a string without a leading dot (e.g. a self-compiled or embedded Python with a misconfigured `pyconfig.h` / `sysconfigdata`).

Common situations: A custom-compiled CPython missing the EXT_SUFFIX macro; a stripped/redistributable Python build (some Linux distros, conda envs, embedded Pythons); a stub or `python-build-standalone` artifact with incomplete sysconfig; running under an unusual interpreter (old IronPython, modified PyPy).

Related errors


AI-assisted analysis of pypa/pip@d7d0d0a394 (2026-08-04). Data as JSON: /data/errors/ba29bb313c5d2105.json. Report an issue: GitHub.