AnsweredAssumed Answered

Can't use debugger in IDE, throws errors when there are none.

Question asked by MollyKFoley on Jan 23, 2018
Latest reply on Aug 31, 2018 by MollyKFoley

EDIT: I moved my code to a different IDE and it works in debug there. It's a problem with PyCharm, anybody know how to fix it?


I have no idea why this is happening, it just started occurring today. My python script runs fine as long as I don't run it in debug mode... in debug mode I get all sorts of errors about datasets not existing or parameters being invalid for certain tools. When I take that chunk of code causing issues, put it in it's own script and run it, it runs just fine. All the datasets DO exist, they all DO have features, all the arcpy statements are written correctly, and for the life of me I cannot fix this. I NEED to be able to use debugger, this is getting ridiculous. 


I'm using PyCharm IDE, just updated to the most recent version. I haven't had this problem before with PyCharm, has anybody else? I'm wondering if it's something with the IDE. I haven't changed much of my code today at all, maybe a few lines. 


I think part of the problem is creating/using in_memory feature classes. To fix this, I attempted to hardcode some of the outputs to my directory instead of using in_memory but it just changed the error message in debug mode to something else, rather than fixing the issue.


This has been a long process of changing error messages and I couldn't describe them all to you if I tried, but one of them arose after trying to run the buffer tool:

qhPolys = arcpy.Select_analysis(svyPtFC, 'in_memory/qhPolys', select_query)
qh_buffer = arcpy.Buffer_analysis(qhPolys, 'in_memory/qh_buffer', '50 Meters')

The error message received here said that qhPolys didn't exist. I changed the in_memory/qhPolys to be hardcoded to my output directory. Still the same error occurs in debug ONLY. Again, I reiterate, the script works just fine if I let it run normally without debugging.


After a bunch of messing around trying to figure out the issue, I eventually just reset the above coded lines to in_memory and debug worked fine through those (for no reason whatsoever, apparently) until a few lines down. Line 5 below started to give me issues saying that "ERROR 000732: Input Features: Dataset # 1;# 2 does not exist or is not supported"

qhPolys = arcpy.Select_analysis(svyPtFC, 'in_memory/qhPolys', select_query)
qh_buffer = arcpy.Buffer_analysis(qhPolys, 'in_memory/qh_buffer', '50 Meters')     
cropFID = '"FID" = {0}'.format(cropPatch)
cropPoly = arcpy.Select_analysis(svyPtFC, 'in_memory/cropPoly', cropFID)
crop_intersect = arcpy.Intersect_analysis([[cropPoly, 1], [qh_buffer, 2]],

I added these lines to determine that cropPoly and qh_buffer are, indeed, populated with features and shouldn't be giving any error messages. When I tested this with debugging on, it magically stepped through this without throwing the above error message like before (what the ****)

feature_count2 = arcpy.GetCount_management(cropPoly)
feature_count3 = arcpy.GetCount_management(qh_buffer)
if feature_count2 > 0 and feature_count3 >0:
        crop_intersect = arcpy.Intersect_analysis([[cropPoly, 1], [qh_buffer, 2]],

THEN on the next line, I got this error message: "Error 000735: Input Row: Value is required"

feature_count = arcpy.GetCount_management(crop_intersect)

crop_intersect has features. I went into ArcMap and checked the attribute table, there are records there to count. THERE IS NO REASON I SHOULD BE GETTING THIS ERROR MESSAGE.


I'm way beyond frustrated at this point. I have shut down and restarted my computer even to see if it was just a glitch. Why won't my script work in debug mode but it works just fine without it?