4

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.3 and Visual studio 2017. My steps

  1. Downloaded the 'Python development' workload to visual studio Pro 2017.
  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:

enter image description here

  1. Ran my script tool in ArcGIS Pro.

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 2017 in ArcGIS Pro?

11
  • I've never gotten "debug arcpy in XYZ" to work in anything other the standard python interpreter and ipython
    – Paul H
    Commented Mar 13, 2019 at 20:31
  • The top link suggests not to connect to ArcGISPro but connect to a Python instance.
    – klewis
    Commented Mar 13, 2019 at 20:44
  • @klewis The link does say to attach visual studio to ArcGIS Pro. It says to attach to 'python code' in visual studio as I did in the image I posted in the original question.
    – ketar
    Commented Mar 13, 2019 at 20:48
  • @PaulH, Esri has demo videos where they get it to work so I figured it's possible.
    – ketar
    Commented Mar 13, 2019 at 20:50
  • I have VS 2017 and I can debug from ArcPro. Open your script in VS, set a breakpoint, attach to Pro, run the script tool from Pro, it should stop at the breakpoint. I have to reattach to ArcPro every time for some reason.
    – klewis
    Commented Mar 13, 2019 at 21:50

1 Answer 1

1

I had the same problem with VS 2019 and ArcGIS Pro 2.8. For me it was because 'Python Code' and '(.NET 4x)' were selected at the attach process. When I just selected the 'Python' it worked.

1
  • Mine has always just been python code. No .net. I have found that on first attaching, it doesn't work but when I detach and re attach after the first attempt, I am able to hit the breakpoints. It's a trial and error process.
    – ketar
    Commented Jun 29, 2022 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.