DOI-USGS / gems-tools-pro

GeMS Tools for ArcGIS Pro
Creative Commons Zero v1.0 Universal
44 stars 15 forks source link

Docx to DMU Fails in Pro 3.3 #111

Open dmirandaUSGS opened 1 month ago

dmirandaUSGS commented 1 month ago

I am using the latest version of Docx to DMU, GeMS_DocxToDMU.py, version of 5/8/24. The tool works in Pro 3.2.x, but fails in 3.3. I get the following message:

  File "C:\ArcGIS\0_ToolBoxes\gems-tools-pro\Scripts\GeMS_DocxToDMU.py", line 33, in <module>
    import docx
  File "C:\ArcGIS\0_ToolBoxes\gems-tools-pro\Scripts\docx\__init__.py", line 14, in <module>
    from docx.parts.document import DocumentPart
  File "C:\ArcGIS\0_ToolBoxes\gems-tools-pro\Scripts\docx\parts\document.py", line 7, in <module>
    from docx.document import Document
  File "C:\ArcGIS\0_ToolBoxes\gems-tools-pro\Scripts\docx\document.py", line 10, in <module>
    from docx.section import Section, Sections
  File "C:\ArcGIS\0_ToolBoxes\gems-tools-pro\Scripts\docx\section.py", line 7, in <module>
    from collections import Sequence
ImportError: cannot import name 'Sequence' from 'collections' (C:\Users\dmiranda\AppData\Local\ESRI\conda\envs\arcgispro-py3-mkdocs\Lib\collections\__init__.py)

I was able to get the tool to work by opening section.py and changing the import statement on line 7 to from collections.abc import Sequence. It seems like Sequence was moved from Collections to Collections.abc across the version of Python Pro 3.3 is now using.

The tool appears to work, and I get a DMU table that looks correct, but I am not sure if this is all that needs to be adjusted.

ethoms-usgs commented 1 month ago

Dan, For those of us who have not updated Pro yet, and may not for a while, could you add a try block and see if that works?

try:
    from collections import Sequence
except:
    from collections.abc import Sequence

If that works for you, I will make the edit on my end and push it out.

dmirandaUSGS commented 1 month ago

The try-except block as written works in Pro 3.3.

ethoms-usgs commented 1 month ago

Excellent! Thank you. I will put it in the next release.