Editing a Python toolbox

A Python toolbox (.pyt) is an ASCII file that can be edited in any text editor or Python IDE.

To edit a Python toolbox from ArcCatalog or the Catalog window, right-click on the toolbox and click Edit. When your edits are finished, your Python toolbox will be automatically refreshed when the editor is closed. Alternatively, to manually refresh a Python toolbox at any time, right-click on the toolbox and click Refresh.

By default, the Python toolbox will open in NotePad. To control the application in which the .pyt file is opened, first set your Editor in Geoprocessing > Geoprocessing Options.

TipTip:

When a Python toolbox is refreshed, only the Python toolbox file itself is refreshed; any modules that are imported within the toolbox are not. To reload a module from within a Python toolbox, Python's reload function can be temporarily added.

Solving toolbox and tool errors

A toolbox icon that shows an error icon (Invalid Python Toolbox) indicates a syntax error. To see an explanation of the problem, right-click the toolbox and click Check Syntax. This opens a Python Errors dialog box, which provides the error type and line number. An error such as Parsing error SyntaxError: invalid syntax (line 40), indicates a syntax error on line 40.

A tool icon that has been replaced with an error icon (Invalid Script) indicates a failure in the tool. To see an explanation of the problem, right-click the toolbox and click Why. This opens a Python Errors dialog box, which provides the error type and line number. This will cover errors in the tool's __init__, getParameterInfo, or isLicensed methods.

Related Topics

3/3/2014