One of my current projects is trying to automate legal documents from my iPad by using Python. I made significant progress and can generate a 50+ page lease with variable fill-ins and different clauses (and even riders) coming in or out. But I’m still improving the process. I’m wrestling with saving the data that a user inputs so I can retrieve it in a later session.
Problem: Deprecation Warning
Documents/site-packages/docx/section.py:7: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.9 it will stop working from collections import Sequence
I mainly identify as a lawyer, so I spend much of my time perusing the law in primary and secondary sources. I don’t mind spending time studying tangential tools (such as Python) to help with my legal practice. But I don’t want to invest my time on something that might be deprecated. So, I reached out to the developer of python-docx-template.
I researched further and learned that the developer of python-docx released a fix on May 15, 2021 in version 0.8.11.
I checked Pyto. As the following screen captures show, it seemed that Pyto was running the latest version (0.8.11) of python-docx:
But I was still getting the deprecation warning:
So, I reached out to the developer of python-docx-template again with the screen captures.
The developer of python-docx-template had what seemed to me to be a cryptic reply: “what gives
pip list?” This question seemed like one of the riddles my father tells in Arabic, where I’m not sure if I understood the riddle or the Arabic. But I like riddles, so I dug further.
I learned that
pip list gives information on pip-managed Python packages.
Based on a comment on StackOverflow, I wrote the following code in Pyto:
import pip pip.main(['list'])
The result surprised me:
Despite my earlier screen captures, Pyto wasn’t using the latest version of python-docx. As the screen capture shows, Pyto was using version 0.8.10 instead of 0.8.11, which has the fix.
I followed the suggestion made by Pyto (see the following screen capture). I deleted python-docx and installed it again. I’m no longer getting the error message!
Now, I can focus on the other document assembly issue I’m wrestling with: data serialization and deserialization in Python.