Select to view content in your preferred language cannot open toolbox file

06-12-2023 04:46 AM
New Contributor III

I'm trying to do the basic example of creating a geoprocessing module found at I have a similar directory structure as in the example, up to the step where it says to run ``. 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;'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\", 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
New Contributor II

You need to edit the toolboxes metatada before running"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 function can be run to generate the supporting .xml files. 

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