I found the docs on using Visual Studio and PyCharm but I wonder if anyone has had success with Visual Studio Code?
I set up launch.json and I can attach to ArcGISPro.exe but I am not sure what comes after that. I can set breakpoints in my .py file from the IDE but they are never hit.
I use F5 to run and wait for the status bar to go orange which indicates it's running. I must be very close, because I can see print() statement output in the IDE's Debug Console window.
I am running ArcGIS Pro 2.8 on Windows 10 using the newest VS Code.
If you are interested in seeing the Python code, it's here
https://github.com/Wildsong/ArcGIS_Python_Template
My launch.json looks like this
{
"version": "0.2.0", "configurations": [
{
"name": "Python: Attach using Process Id",
"type": "python",
"request": "attach",
"processId": "${command:pickProcess}"
},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
Happy Friday!
Hi Brian,
Did you ever find a resolution to this? I'm in the same boat currently. Thanks.
what worked for me
1. run ArcGIS pro (3.0)
2. open vs code with the script open
3. in vs code run and Debug , then select attach using process ID
and select the ArcGIS pro processed
run the gp tool in ArcGIS pro
Doesn't seem to work for me. It seems to attach but it runs in AGP without hitting the breakpoints.
I tried a couple different routes:
1. Debug on the tool script
2. Debug on the toolbox (pyt)
3. Removing and re-adding the toolbox.
I get the debug pane in VS (variables, call stack, etc) but no breakpoints. How is your toolbox laid out?
since the move to arcPro 3
its not working as expected
For me it does work with debugpy breakpoints but not with visualstudio breakpoints. For using debugpy import debugpy in your python tool file (.pyt) :
import debugpy
on those lines where you want the debugger to stop, call debugpy's breakpoint() method:
debugpy.breakpoint()
Then run and debug add a debug configuration that let's you pickup the Process ID of the running ArcGIS Pro application:
{
"name": "Python: Attach using Process Id",
"type": "python",
"request": "attach",
"processId": "${command:pickProcess}",
"justMyCode": true
}
Start debugging, wait for the debugger to connect and then run the Python Tool in ArcGIS Pro. The debugger will stop wherever the debugpy.breakpoint() call was set.
I have taken to running the tools outside AGP entirely. It has sped up development by sidestepping the 'reload toolbox' requirement. That said, I would still like to get this going if anyone finally cracks this.
I've just come across this post after searching for the solution for a while, this was the closest I got as well. I can see print commands but can't see any of the variables or watched expressions. Anyone managed to get this working in the last year?
I used this blog, which helped me create a .py file that I can use with vs code to debug using the default launch.json:
https://www.esri.com/arcgis-blog/products/arcgis-desktop/analytics/how-to-debug-python-toolboxes-in-...
here are other resources that might be of interest:
https://mfcallahan.blog/2022/10/11/configuring-vs-code-for-arcpy-arcgis-pro-development/
https://github.com/microsoft/debugpy/issues/431