Open-source DOCX comparison tool, powered by the Docxodus engine, to generate native Word tracked changes (redlines) in Python without MS Word dependencies.
Actively maintained. Last release 6 days ago, commits in 5 of the last 26 weeks. A safe choice.
pip install python-redlinespython-redlines
Generate tracked-change "redline" .docx documents by comparing two Word files.
python-redlines is the pure-Python core. The comparison engines themselves are
compiled .NET binaries shipped in separate, optional companion packages — install
the one(s) you need as extras:
pip install python-redlines[docxodus] # Docxodus engine
pip install python-redlines[ooxmlpowertools] # Open-XML-PowerTools engine
pip install python-redlines[all] # both
Binaries are prebuilt for each platform and embedded in the companion package's wheel — no .NET SDK and no local compilation are needed to install or use it.
Usage
from python_redlines import DocxodusEngine
engine = DocxodusEngine()
redline_bytes, stdout, stderr = engine.run_redline(
"Author Name",
original=open("original.docx", "rb").read(),
modified=open("modified.docx", "rb").read(),
)
DocxodusEngine runs DocxDiff. The engine selector was removed in 1.0.0 along
with WmlComparer. See the project README
for supported settings.
From 2.0.0 onward, each extra pins its companion package to the same release
version as the wrapper. For older releases, pin both packages explicitly (for
example, python-redlines[docxodus]==0.3.0 and
python-redlines-docxodus==0.3.0). Existing published metadata is unchanged.
3.0.0 bundles Docxodus v17.0.0 and adds one setting, minimum_anchor_word_count.
Existing call signatures and settings are unchanged from 2.0.0, but comparison markup
and revision counts can differ, and some very deeply nested documents are now refused.
It requires Python 3.11 or newer; 2.0.0 was the last release to support 3.9 and 3.10.
Review representative redlines when upgrading; see the
3.0.0 migration guide.
An unsuccessful engine exit raises EngineExecutionError, a subclass of
subprocess.CalledProcessError. Its message includes the captured stderr and
stdout; returncode, cmd, stdout/output, and stderr remain available.
If an engine's companion package is not installed, instantiating the engine
raises EngineNotInstalledError with the pip install command to fix it.
See the for details.