OR-Dept-Environmental-Quality / TTools

TTools
GNU General Public License v3.0
4 stars 1 forks source link

step 3: dict_keys has no attribute sort #3

Open coltenelkin opened 4 months ago

coltenelkin commented 4 months ago

Ran into an issue in step 3 while processing nodes that 'dict_keys has no attribute sort' on lines ~505 and ~555. Managed to solve the issue by adding a line that transforms the type of variable from dict_keys to list, which is sortable. This update may be related to the fact that I'm now running python 3.12; I didn't have this problem when running python 3.8. An example fix is below: # Get a list of the nodes, sort them nodes = nodeDict.keys() nodes.sort() n_nodes = len(nodes)
Old code; the nodes.sort() line threw an error. # Get a list of the nodes, sort them nodes = nodeDict.keys() nodes = list(nodes) # CME edit to try to bypass 'dict_keys has no attribute sort' error nodes.sort() n_nodes = len(nodes) New code without the error.

DEQrmichie commented 4 months ago

Hi @coltenelkin. Thanks for looking at this stuff. TTools was written for Python 2.7 so there will definitely be some bugs if using Python 3. We have a Python 3.8 + TTools planned and that work should start very soon. I will keep this edit in mind for that version.

coltenelkin commented 4 months ago

thanks @DEQrmichie. I just updated from using ArcMap 10.7 to ArcGIS Pro 3.2.0 on my machine yesterday and am re-running the TTools files in the python window to see how it rolls. There were a few other issues in TTools steps 4 and 5, but they were substantially similar to the issue flagged in the first post above. Hoping to leave this here in case other folks run into a similar error using the python window in ArcPro.