Skip to content

docxcompose is not longer installed as dependency in version 0.20.2 #629

Open

Description

@stefankaufmann

The following code does not work anymore after docxcompose has been removed from the required dependencies

my_template = DocxTemplate(some_path)
sub_doc = my_template.new_subdoc("subdoc1")

The error is

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    # -*- coding: utf-8 -*-
    """
    Created : 2021-07-30
    
    @author: Eric Lapouyade
    """
    
    from docx import Document
    from docx.oxml import CT_SectPr
    from docx.opc.constants import RELATIONSHIP_TYPE as RT
>   from docxcompose.properties import CustomProperties
E   ModuleNotFoundError: No module named 'docxcompose'

Our requirements.txt file refers to docxtpl like

docxtpl~=0.20.0

Our code worked for version 0.20.1 and is broken for 0.20.2

Actually I think such a refactoring should not be part of a patch release but should at least have been part of a minor release. We pinned the version to be protected against such breaking changes.

Activity

  1. janmarsino98 commented on Jul 14, 2026

    @janmarsino98

    I reproduced this from a clean Python 3.14 virtual environment with the current project installed from source and only its mandatory dependencies (python-docx, jinja2, and lxml). docxcompose was absent and DocxTemplate(...).new_subdoc() raised ModuleNotFoundError: No module named 'docxcompose' while importing docxtpl.subdoc.

    The dependency is correctly declared as the optional subdoc extra. Would a small guard in new_subdoc() be acceptable? It could raise a clear error such as:

    new_subdoc() requires the optional docxcompose dependency. Install it with: pip install docxtpl[subdoc]
    

    I would keep docxcompose optional and add a focused test that simulates its absence. If this direction is acceptable, I can prepare that minimal PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions