-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Non compatibility of new update 1.1.1 with python-docx-template #1385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@lcpprop I believe this error is due to the effect of this commit: In particular, getting rid of the highlighted legacy implementation of Unfortunately, it looks like I believe this can be fixed simply by dropping the leading underscore: Unfortunately I expect that will require a new release of |
@lcpprop I'm going to try adding a |
@lcpprop can you do a fresh install from the pip uninstall python-docx
pip install git+https://github.com/python-openxml/python-docx@develop I added in a |
Also got |
Thanks @marcindulak :) That's a big help to me :) I'm still fixing a couple tests to support Python 3.12 but I hope to have the v1.1.2 release out today :) |
Okay, v1.1.2 is up on PyPI :) |
I am using python-docx-template to generate a word document report by populating my word template. Yesterday evening (before update 1.1.1), I ran my code and everything was working smoothly. Now, in the morning (after update 1.1.1) and I get an error when running the same code:
AttributeError Traceback (most recent call last)
File , line 90
89 template_vars {"name":"John", "lastname":"Oliver"}
---> 90 doc.render(template_vars)
92 doc.save("<path_to_save>".docx")
File /local_disk0/.ephemeral_nfs/envs/.../lib/python3.10/site-packages/docxtpl/template.py:382, in DocxTemplate.render(self, context, jinja_env, autoescape)
379 # Headers
380 headers = self.build_headers_footers_xml(context, self.HEADER_URI,
381 jinja_env)
--> 382 for relKey, xml in headers:
383 self.map_headers_footers_xml(relKey, xml)
385 # Footers
File /local_disk0/.ephemeral_nfs/envs/.../lib/python3.10/site-packages/docxtpl/template.py:338, in DocxTemplate.build_headers_footers_xml(self, context, uri, jinja_env)
337 def build_headers_footers_xml(self, context, uri, jinja_env=None):
--> 338 for relKey, part in self.get_headers_footers(uri):
339 xml = self.get_part_xml(part)
340 encoding = self.get_headers_footers_encoding(xml)
File /local_disk0/.ephemeral_nfs/envs/.../lib/python3.10/site-packages/docxtpl/template.py:324, in DocxTemplate.get_headers_footers(self, uri)
323 def get_headers_footers(self, uri):
--> 324 for relKey, val in self.docx._part._rels.items():
325 if (val.reltype == uri) and (val.target_part.blob):
326 yield relKey, val.target_part
AttributeError: 'DocumentPart' object has no attribute '_rels'
Since, package python-docx-template specifies in their requirements.txt to install the latest version of all the required packages
six
python-docx
docxcompose
jinja2
lxml"
and does not specify which version, the newest update has broken it. Now, that I specified that I want python-docx == 1.1.0, the code started working again. Please help.
The text was updated successfully, but these errors were encountered: