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 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Select_analysis<SPAN class="punctuation token">(</SPAN>svyPtFC<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'in_memory/qhPolys'</SPAN><SPAN class="punctuation token">,</SPAN> select_query<SPAN class="punctuation token">)</SPAN>
qh_buffer <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Buffer_analysis<SPAN class="punctuation token">(</SPAN>qhPolys<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'in_memory/qh_buffer'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'50 Meters'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN></SPAN>
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 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Select_analysis<SPAN class="punctuation token">(</SPAN>svyPtFC<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'in_memory/qhPolys'</SPAN><SPAN class="punctuation token">,</SPAN> select_query<SPAN class="punctuation token">)</SPAN>
qh_buffer <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Buffer_analysis<SPAN class="punctuation token">(</SPAN>qhPolys<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'in_memory/qh_buffer'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'50 Meters'</SPAN><SPAN class="punctuation token">)</SPAN>
cropFID <SPAN class="operator token">=</SPAN> <SPAN class="string token">'"FID" = {0}'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>cropPatch<SPAN class="punctuation token">)</SPAN>
cropPoly <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Select_analysis<SPAN class="punctuation token">(</SPAN>svyPtFC<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'in_memory/cropPoly'</SPAN><SPAN class="punctuation token">,</SPAN> cropFID<SPAN class="punctuation token">)</SPAN>
crop_intersect <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Intersect_analysis<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">[</SPAN>cropPoly<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN>qh_buffer<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN>
r<SPAN class="string token">'C:\Users\xyz\GIS_Testing\intersect2.shp'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>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 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetCount_management<SPAN class="punctuation token">(</SPAN>cropPoly<SPAN class="punctuation token">)</SPAN>
feature_count3 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetCount_management<SPAN class="punctuation token">(</SPAN>qh_buffer<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">if</SPAN> feature_count2 <SPAN class="operator token">></SPAN> <SPAN class="number token">0</SPAN> <SPAN class="operator token">and</SPAN> feature_count3 <SPAN class="operator token">></SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN>
crop_intersect <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Intersect_analysis<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">[</SPAN>cropPoly<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN>qh_buffer<SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN>
r<SPAN class="string token">'C:\Users\xyz\GIS_Testing\intersect2.shp'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
THEN on the next line, I got this error message: "Error 000735: Input Row: Value is required"
feature_count <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetCount_management<SPAN class="punctuation token">(</SPAN>crop_intersect<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
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?