How to debug arcpy code in visual studio 2019

230
2
05-13-2021 02:41 PM
ManishShrivastav
New Contributor III
# This script clips all feature classes in a file geodatabase

import arcpy

# Create path variables
sourceWorkspace = r"C:\Users\Lesson2Practice\USA.gdb"
targetWorkspace = r"C:\Users\Lesson2Practice\Iowa.gdb"
clipfeature = r"C:\Users\Lesson2Practice\Iowa.gdb\Iowa"

# Get a list of all feature classes in the USA geodatabase
arcpy.env.workspace = sourceWorkspace
featureClassList = arcpy.ListFeatureClasses()

try:
    # Loop through all USA faeture classes
    for featureClass in featureClassList:
        
        # Construct the output path
        outClipFeatureClass = f'{targetWorkspace}\Iowa{featureClass}'

        # Perform Clip
        arcpy.Clip_analysis(featureClass,clipfeature,outClipFeatureClass)
        arcpy.AddMessage(f'Wrote clipped file {outClipFeatureClass}.')
        print(f"Wrote clipped file {outClipFeatureClass}.")
except:
    # Report if there was an error
    arcpy.AddError("Could not clip feature classes")
    print("Could not clip feature classses")
    print(arcpy.GetMessages())

I have created a python script file that I am debugging it using visual studio 2019, But as soon as I try to debug, it gives me and Exception on another file (time.py - not sure where it came from as this time.py is not in my project or folder) stating "name 'm' is not defined" (I am attaching a video of the exception). Any help is appreciated.

 

Thanks

0 Kudos
2 Replies
GintautasKmieliauskas
Regular Contributor

Hi,

Have you solved issue with "name 'm' is not defined"?

I have the same situation as you

0 Kudos
ManishShrivastav
New Contributor III

I am still waiting for it.

0 Kudos