Summarize within -- ModuleNotFoundError: No module named 'common'

2984
8
02-06-2024 01:43 PM
MeganEngel
Frequent Contributor

Been running into this issue for a while now, and previously I just did a big multi step work around, but now it is just getting annoying to have to keep doing that within the code.  I simply get this error:

Traceback (most recent call last):
  File "C:\Users\USERNAME\GIS Share Drive\_Resources\Toolboxes\Toolbox.atbx\ToolName.tool\tool.script.execute.py", line 26, in <module>
ModuleNotFoundError: No module named 'common'

 Here is the portion of the code we get hung up on:

 # Process: Summarize Within (Summarize Within) (analysis)
arcpy.AddMessage(f"Generate crop history summary table.")
Crop_Summary = f"{OutputLocation}\\Crop_{Year}_Summary"
Class_Names_Summary = f"{OutputLocation}\\Crop_{Year}_Class_Names_Summary"
arcpy.analysis.SummarizeWithin(in_polygons=Field_Boundary,
in_sum_features=Crop_poly,
out_feature_class=Crop_Summary,
keep_all_polygons="KEEP_ALL",
sum_fields=[['gridcode','SUM']],
sum_shape="ADD_SHAPE_SUM",
shape_unit="ACRES",
group_field="Class_Names",
add_min_maj="ADD_MIN_MAJ",
add_group_percent="ADD_PERCENT",
out_group_table=Class_Names_Summary)

 

We have reviewed all out output locations, types, and inputs and everything works as expected when running those through the tool in the traditional GUI.  However, since this is just 1 step in a larger process we want it in our custom script tool.

 

Any help would be MUCH appreciated. 

0 Kudos
8 Replies
DanPatterson
MVP Esteemed Contributor

Where are the imports?

Are you running your toolbox from a local install or elsewhere?

There are probably dozens of "common" folders and "common.py" modules with the arcgis pro installation path, so it might be an import that you aren't expecting (in creating the tool/toolbox perhaps) that is doing the import)


... sort of retired...
0 Kudos
MeganEngel
Frequent Contributor

We are running this on a local install.

 

Here are the Imports in our custom script:

import arcpy
from arcpy import env
import os
import time
import subprocess
import datetime
import getpass
import csv

 

It is important to note this error started happing after we updated ArcPro to 3.2 from 3.1.  We've also tried the classic uninstall and reinstall in case there was an error there.

0 Kudos
aclark2_fanshawe
Emerging Contributor

I am running into the same problem. I teach Python at Fanshawe College and everything works on the lab computers which are running ArcGIS Pro 3.1.3, but not on laptops that are upgraded to 3.2.2. Also important to note, the SummarizeWithin from Analysis toolbox works fine in model builder, fine in Jupyter, but not when integrating into a Script tool. Just doesn't make any sense.

 

0 Kudos
MeganEngel
Frequent Contributor

@aclark2_fanshawe, I had been working with ESRI for a while on this ticket and we could not figure out why it wasn't workin' in the script tool.  They were able to run it no problem on multiple machines with the same software version etc.  Same thing we found, I can run it in python, jupyter, model builder, and the model builder GUI, just not a script tool GUI. SO ODD!

 

The final resolution for my organization was to just run it all in python/Jupyter, because the script was short enough.  For our more complex script it had been in before, I just ended up re-writing a bunch of stuff taking a single step to 5 steps to get the result.  Not ideal

0 Kudos
DanPatterson
MVP Esteemed Contributor

I would report it to Tech Support if it worked fine in 3.1 and is now a bug in 3.2

They have more resources to identify conflicts in package imports and related issues.


... sort of retired...
0 Kudos
JMarcel192
Occasional Contributor

So ESRI decided to move, downgrade the tool (by numeric summary) and reintroduced the tool through their “Geoanalytics Desktop Tool” using Apache Spark, the tools library is under “arcpy.gapro.SummarizeWithin(“ and has a reference website. It has a completely new schema, similar conclusions, more powerful capabilities, and giving me some weird, inconsistent outputs. 

 

- Hope that helps

0 Kudos
JMarcel192
Occasional Contributor

Also, if ESRI is listening, the “majority” percentage is returning values greater than 100% (by float: I’m getting 100.00000003). 

0 Kudos
jacob_ekn
Occasional Contributor

Did you ever resolve this issue? I'm having the same problem now. It could have something to do with me moving the tool onto my work's NAS but it was working perfectly fine as is yesterday so I'm not sure. I kind of tried @JMarcel192's solution and tried using arcpy.geoanalytics.SummarizeWithin but that gave me an "Unable to get GeoAnalytics URL" error even though the GeoAnalytics Desktop tool works perfectly fine in ArcGIS Pro.

0 Kudos