Main Ecosystems
HomePython CorePandas ReferenceNumPy ScientificFastAPI & PydanticDjango Enterprise
More Ecosystems
Environment & SetupRequests & HTTPAsyncIO ConcurrencyObject-Oriented OOPPyTorch Deep LearningScikit-Learn MLFlask FrameworkWeb ScrapingDatabase & ORMDevOps & Docker

Solve the xmlsec Error: 100 Installation Failure in Python

Verified FixPython 3.10+xmlsec 1.3+Silo: environment

Quick Fix / Solution Rapide

Install underlying C development headers (libxmlsec1-dev, libxml2-dev, libxslt1-dev on Linux or brew install libxmlsec1 on macOS) before running pip install xmlsec.

Root Cause Analysis

This error occurs when Python tries to compile the xmlsec package (a Python wrapper around the XML Security Library) from source, but the C compiler cannot find required system header files (xmlsec.h, libxml2, or xmlsec1-openssl).

1. Missing Native C Development Libraries

xmlsec is a native C-extension that binds directly against libxmlsec1, libxml2, and OpenSSL. Unlike pure Python libraries, it cannot be compiled from source without corresponding system development header packages installed on the host OS.

2. Missing pkg-config Tool

The xmlsec build script invokes pkg-config --cflags --libs xmlsec1 to determine include directories and linker paths. If pkg-config is missing from the system PATH, configuration fails with error code 100 or exit status 1.

3. Minimal Docker Container Images

Docker base images like python:3.12-slim omit system development libraries by default to minimize image size.

4. Homebrew Prefix Mismatches on macOS

On Apple Silicon Macs, Homebrew installs libraries into /opt/homebrew/include, which standard compiler flags may not search without PKG_CONFIG_PATH set.

Reproduction Code (MCVE)

Example: Bug Reproduction
# **Note de reproductibilité :** Dépendant des dépendances de l'OS.
raise OSError('xmlsec installation error: (100, "Could not find xmlsec1 development headers via pkg-config")')

Solution 1: Install System Development Packages (Linux & macOS)

Install libxmlsec1 development libraries using the native system package manager.

Example: Recommended Solution
import sys

print('On Debian/Ubuntu:')
print('sudo apt-get update && sudo apt-get install -y libxmlsec1-dev libxml2-dev libxslt1-dev pkg-config')
print('On macOS (Homebrew):')
print('brew install libxmlsec1 libxml2 libxslt pkg-config')
print('export PKG_CONFIG_PATH="/opt/homebrew/opt/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH"')

Solution 2: Dockerfile Multi-Stage Build Pattern

Include required system libraries in your Docker build configuration before installing Python dependencies.

Example: Alternative Solution
print('Add to Dockerfile:')
print('RUN apt-get update && apt-get install -y --no-install-recommends \\')
print('    build-essential pkg-config libxmlsec1-dev libxmlsec1-openssl \\')
print('    && rm -rf /var/lib/apt/lists/*')
print('RUN pip install --no-cache-dir xmlsec')

A common mistake is installing libxmlsec1 without the -dev suffix on Ubuntu. The base package contains only runtime .so binaries; compiling Python extensions requires the C header files (.h) located in -dev. On Windows, compiling xmlsec requires pre-built binaries or vcpkg. Using pre-built wheels via pip install xmlsec is strongly recommended. Contrast this error with ModuleNotFoundError: No module named 'xmlsec', which occurs when the package build failed and was never installed.