Select to view content in your preferred language

Difficulties debugging ArcPy in Visual Studio 2019

517
2
04-01-2022 12:37 PM
JimGrinwald
New Contributor II

I have a script that is trying to use and SDE database connection and do a few operations, namely

  • arcpy.GenerateNearTable_analysis
  • arcpy.da.SearchCursor

among other things.  While I can set up and debug through these operation in ArcGISPro and Idle, having a project set up in Visual Studio using the same Python environment as in ArcGISPro will fail at these steps.  The table names are fully qualified, i.e., <path_to_sde_file>\<Table_name>, and the Idle debugger will execute the line successfully, but Visual Studio debugger typically fails with an indication that it cannot find / open the table.

It is really concerning, as there are other operations in the script where I really need great visualization of the local variables that the VS debug IDE provides, and Idle simply does not.

Any help or input would be greatly appreciated.

Regards, 

Jim

  

0 Kudos
2 Replies
KimGarbade
Regular Contributor

I'll start by saying I've never configured Visual Studio to write Arcpy code before and don't use it for Arcpy, but it sounds to me like maybe Visual Studio isn't configured correctly to use Arcpy.  All I could find that might help with this is the below link.

What I have used is Spyder which works like a charm for me and does show you the values of variables and a has a console for viewing messages and errors. It's also pretty easy to install and free. 

I get wanting to use only one environment for all development, but if you can use something else you might try Spyder. 

https://gis.stackexchange.com/questions/203380/setting-up-python-arcpy-with-arcgis-pro-and-visual-st....

0 Kudos
by Anonymous User
Not applicable

Visual Studio really expects that you are building structured projects/ applications and in my experience, struggles with single python scripts. Try PyCharm too. It has great debugging support and not to start an IDE war, but has been more stable than Spyder in my use.

0 Kudos