@@ -65,6 +65,60 @@ Alpine
6565 Troubleshooting
6666***************
6767
68+ ``lxml & xmlsec libxml2 library version mismatch ``
69+ --------------------------------------------------
70+
71+ ``xmlsec `` passes ``lxml `` XML nodes to the underlying ``xmlsec1 ``
72+ library. Both libraries use ``libxml2 ``, so they must use compatible
73+ ``libxml2 `` versions at runtime. If ``lxml `` is installed from a wheel
74+ that bundles one ``libxml2 `` version while ``xmlsec `` is built against
75+ another system ``libxml2 ``, importing or using ``xmlsec `` can fail with:
76+
77+ .. code-block :: text
78+
79+ xmlsec.InternalError: (-1, 'lxml & xmlsec libxml2 library version mismatch')
80+
81+ The most reliable fixes are:
82+
83+ * Use prebuilt wheels for both ``lxml `` and ``xmlsec `` when wheels are
84+ available for your platform:
85+
86+ .. code-block :: bash
87+
88+ pip install --only-binary=lxml,xmlsec lxml xmlsec
89+
90+ * If you need to build from source, build both packages against the same
91+ locally installed ``libxml2 ``:
92+
93+ .. code-block :: bash
94+
95+ pip install --no-binary=lxml,xmlsec lxml xmlsec
96+
97+ Do not mix a wheel-built ``lxml `` with a locally built ``xmlsec ``, or the
98+ other way around, unless you know they use the same ``libxml2 `` version.
99+
100+ An ``lxml `` release upgrade does not by itself mean ``xmlsec `` is
101+ incompatible; this error is about the ``libxml2 `` libraries loaded in
102+ that environment.
103+
104+ If the error appears only under uWSGI, uWSGI may have loaded the system
105+ ``libxml2 `` before Python imports ``lxml `` or ``xmlsec ``. In that case,
106+ make sure uWSGI and the Python packages resolve to the same ``libxml2 ``,
107+ or rebuild the Python packages from source in that environment. If you
108+ use ``uv ``, clear any cached mixed builds before reinstalling. For
109+ example, to reinstall from wheels:
110+
111+ .. code-block :: bash
112+
113+ uv pip uninstall lxml xmlsec
114+ uv cache clean
115+ uv pip install --only-binary lxml --only-binary xmlsec lxml xmlsec
116+
117+ For background, see `issue #356 <https://github.com/xmlsec/python-xmlsec/issues/356 >`_
118+ and the uWSGI edge case in
119+ `issue #415 <https://github.com/xmlsec/python-xmlsec/issues/415 >`_.
120+
121+
68122Mac
69123---
70124
0 commit comments