Debugging Python script using Visual Studio in ArcGIS Pro?

1690
4
06-02-2020 05:11 PM
ManishShrivastav
New Contributor III

According to these links, one can debug a Python script using Visual Studio in ArcGIS Pro. Debug Python code—ArcPy Get Started | ArcGIS Desktop

ArcGIS Pro and Python - YouTube

I am using ArcGIS pro version 2.5.1 and Visual studio 2019 (16.6.1) . My steps

  1. Downloaded the 'Python development' workload to visual studio Pro 2019.
  2. Edited my .py file to add some intentional errors for testing.
  3. Opened ArcGIS Pro with my tool and my data to be run.
  4. Opened my .py file in Visual Studio and added some breakpoints.
  5. Attached to process in Visual Studio. See image below:
  6. Ran my script tool in ArcGIS Pro.
  7. The tool fails in ArcGIS Pro because it has errors but I am not re routed to Visual Studio to see the error line as I expected. I then removed the errors in the code and left only the breakpoints but I still wasn't able to hit the breakpoints. Again, the tool completed without re-routing me back to visual studio. Has anyone been able to successfully debug Python tools using Visual Studio Pro 2019 in ArcGIS Pro 2.5.1?

0 Kudos
4 Replies
DanPatterson
MVP Esteemed Contributor

Did you follow the instructions in Debug Python code—ArcPy Get Started | Documentation ?

There is no mention of supported versions however.


... sort of retired...
0 Kudos
ManishShrivastav
New Contributor III

Yes, Dan. I did exactly as explained here https://pro.arcgis.com/en/pro-app/arcpy/get-started/debugging-python-code.htm   but without any success.

0 Kudos
DanPatterson
MVP Esteemed Contributor

Manish Shrivastav‌ 

Debug Python code

Note:

Microsoft Visual Studio 2017 can be used to debug ArcGIS Pro 2.1 and later. Earlier versions of either of these applications will not work.

Didn't notice that on first look.  You will have to wait for someone else... I am a Spyder user.


... sort of retired...
0 Kudos
ManishShrivastav
New Contributor III

@Dan Patterson

Thanks for pointing it out. I am still using more recent versions of both visual studio pro 2019 as well as ArcGIS Pro 2.5.1

0 Kudos