arcpy.gp.createtoolboxsupportfiles cannot open toolbox file

356
1
06-12-2023 04:46 AM
quillaja
New Contributor III

I'm trying to do the basic example of creating a geoprocessing module found at https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/extending-geoprocessing-thro.... I have a similar directory structure as in the example, up to the step where it says to run `arcpy.gp.createtoolboxsupportfiles()`. Thus, I don't have the `esri` folder yet. When I try to run the arcpy function, I get an error saying it cannot open the toolbox file.

python -c "import arcpy; arcpy.gp.createtoolboxsupportfiles(r'D:\misc_proj\arcgis\pkg_template\Src\ROOT\SampleToolbox.pyt')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
RuntimeError: Cannot open D:\misc_proj\arcgis\pkg_template\Src\ROOT\SampleToolbox.pyt

The file is definitely there, and definitely readable.

Any help about the error is appreciated. Thanks. 

0 Kudos
1 Reply
awesomeLLama27
New Contributor II

You need to edit the toolboxes metatada before running arcpy.gp.createtoolboxsupportfiles(r"path/to/toolbox.pyt").

From Arcpy docs: Once the Toolbox.pyt toolbox has been created, the parameter help can be configured for the toolbox through the metadata. To edit a tool's metadata, from the Catalog pane, right-click the tool in the toolbox and choose Edit Metadata.

After the metadata is updated for the tool and toolbox, the arcpy.gp.createtoolboxsupportfiles function can be run to generate the supporting .xml files. 

A little late but hopefully this helps for someone down the road. Cheers. 

0 Kudos