I've created a Python toolbox using the Python toolbox template. I've configured Visual Studio 2017 to recognize .pyt files as Python files. I've used the instructions here to set up debugging for my Python toolbox.
To debug, I attach the Visual Studio debugger to the ArcGISPro.exe process as Python code, as shown in the screen shot below. I've set breakpoints in my code. However, when I run a tool from the toolbox, none of the breakpoints are hit.
Does anyone have any insight as to why I can't debug?
Visual Studio 2017
ArcGIS Pro 2.2
Python 3.6
Hi there,
Did you ever work this out?
It does work if you add a class and debug in there - so it seems to be that VS doesn't recognise the .pyt as a python file for the debugger. I tried adding it through the registry but had little success. Did you get a solution?
Thanks
Fraser
Hi,
For anyone else looking for this - the answer is in the help page:
https://pro.arcgis.com/en/pro-app/arcpy/get-started/debugging-python-code.htm
IDEs can only debug Python files (.py). For code in a Python toolbox (.pyt file), copy the code to an external Python file, and replace the code in the Python toolbox with the example below. You can then open the Python file in your IDE and set breakpoints, attach the IDE to ArcGIS Pro, and use your Python toolbox. Upon completion of code modification, copy the contents of the Python file back into the Python toolbox.
In the following example, pyt_code.py contains the code usually found in the Python toolbox and is saved to the same directory as a .pyt file.
from pyt_code import *
The section at the top is a bit misleading as it says
Debugging method | Attach to running processes |
---|---|
Supported ArcGIS Pro components |
|
so it really should link to the bottom of the page.
Anyway works as expected.