Select to view content in your preferred language

Issue with Geoprocessing Modules and Standard Toolboxes

387
0
09-21-2022 11:52 AM
DavidSolari
MVP Regular Contributor

The Pro geoprocessing system has this neat feature buried in the docs where you can create standard Python packages that contain script tools, then install those packages to your current environment with the accompanying toolbox infrastructure. More info here. The docs use a Python toolbox in their examples but there's mentions of supporting standard toolboxes as well, most notably in the introduction to the page I linked. However, when I build a package with a standard toolbox and then install it, attempting to run the tool in Pro 3.0.1 results in this error:

 

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\JDangermont\AppData\Local\ESRI\conda\envs\testing\Lib\site-packages\foo\esri\arcpy\SampleToolbox.py", line 20, in SampleTool
    raise e
  File "C:\Users\JDangermont\AppData\Local\ESRI\conda\envs\testing\Lib\site-packages\foo\esri\arcpy\SampleToolbox.py", line 17, in SampleTool
    retval = convertArcObjectToPythonObject(gp.SampleTool_SampleToolbox(*gp_fixargs((), True)))
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 510, in __getattr__
    val = getattr(self._gp, attr)
AttributeError: Object: Tool or environment <SampleTool_SampleToolbox> not found

 

This could be some weird misconfiguration or environment problem on my end so I've attached a little package that you can download, build, and add to your testing environment. You can build the package using the standard instructions, install it with pip, relaunch Pro and then run arcpy.SamplePythonToolbox.SampleTool() and arcpy.SampleToolbox.SampleTool() from the Python window.

If the first tool succeeds but the second tool fails then it's safe to say atbx files aren't actually compatible with this packaging system. If so I hope someone from esri can dig into this as it's most likely just an issue with the autogenerated wrapper code.

0 Kudos
0 Replies