daniel_jimenez86

Python stop working  when closing an arcpy script

Discussion created by daniel_jimenez86 on Feb 7, 2014
Hello, Im created a script that take a .tab file and join it to a shapefile. The script works perfectly but when it finish it gives me an handled exception. I dont know what might be causing it but i think i have identify where its happening. I wanted to ask if someone could help me identify it so i can fix it. Im using arcpy 10.1 and python 2.7. I think its happening in this part. For all the variables i get values prior this portion of the script. I do the same calculation for other fields so this code repeats itself but for different columns

 #Cerate and calculate new fields
            #Population
            if(p == 1):
                pop_calc = '!pop_20{}!-!pop_2010!'.format(year)
                arcpy.AddField_management(outFeature, "pop_diff","LONG",15,"","","","")
                arcpy.CalculateField_management(outFeature,'pop_diff',pop_calc,"PYTHON_9.3")
                arcpy.AddField_management(outFeature, "popShare","DOUBLE",15,10,"","","")
                popSharedTotal = 0            
                popFields = 'pop_diff'
                with arcpy.da.SearchCursor(fc, popFields)as cursor:
                    for row in cursor:
                        popSharedTotal = row[0] + popSharedTotal                    
                arcpy.AddField_management(outFeature, 'temp',"LONG",15,"","","","")
                arcpy.CalculateField_management(outFeature,'temp',popSharedTotal,"PYTHON_9.3")
                arcpy.CalculateField_management(outFeature,'popShare','[pop_diff]/[temp]',"VB")
                arcpy.DeleteField_management(outFeature,'temp')


i can provide the entire script if needed but by commenting sections, this portion is what makes python not close correctly when done with the script.

Outcomes