I am trying to make an executable .exe using pyinstaller on python code that is using the package docxtpl as well as homemade docx templates.
I am using Windows 10 together with conda 4.8.2 and python 3.7.6
The context is a program that produces automatically reports by filling a docx template. The program is working well when it is not an executable and I also manage to produce an executable. The problem occurs when I execute my executable.
I get this error message:
docx.opc.exceptions.PackageNotFoundError: Package not found at
C:\Users\username\AppData\Local\Temp\_MEI100562\mytool\src\report_template\ReportTemplate.docx
Where as in the spec file I used the following data:
datas=[('C:\\Users\\username\\eclipse-workspace\\different_stuff\\allmytools\\mytool\\src\\report_template','ReportTemplate.docx')]
Inside the program:
from docxtpl import DocxTemplate, InlineImage
from docx.shared import Mm
[...]
self.template_dir = join(dirname(dirname(__file__)), 'report_template')
self.template_name = "ReportTemplate.docx"
self.doc = DocxTemplate(join(self.template_dir, self.template_name))
I would be very grateful if somebody could tell me how I can integrate my docx template into the executable so that it works.
Apparently somebody has had the same problem here, but I found no satisfying solution: https://github.com/elapouya/python-docx-template/issues/35