Python toolbox runtime debugging needed

412
3
12-11-2012 01:12 PM
Status: Implemented
Labels (1)
curtvprice
MVP Esteemed Contributor
Currently if a Python toolbox causes an error on import, it shows up in the tool listing with a red x.

If it's a syntax error, fine enough, that has been handled in the interface. However, if it's a runtime error, there's a red X but no way to check it. The only way i can check it is to copy the .pyt to .py and try to import it.

As an example, I created an empty pyt in ArcCatalog and modified it slightly. This has no syntax errors, but I get a red X because the code fails when ArcCatalog tries to load it:

0EME0000000TUqK


It would be great to have a tool or functionality that does a runtime check of .pyt files by attempting an import and reporting any runtime errors.
3 Comments
curtvprice
The geoprocessing team posted a blog post just on this topic!

http://blogs.esri.com/esri/arcgis/2012/12/14/how-to-debug-python-toolboxes-in-3-easy-steps/
ChrisFox
In the specific scenario you described above you should be able to right-click the tool and select "Why" this will bring up a dialog box that will print the exception that was raised.

Traceback (most recent call last):
File "<string>", line 21, in __init__
ImportError: No module named foo
HannesZiegler
Status changed to: Implemented

This is implemented in ArcGIS Pro. When a tool fails at runtime, hover over the error banner to view the error messages.

HannesZiegler_1-1660579246395.png