Can someone reproduce this issue; PyCharm/ArcPy Errors

405
2
01-25-2018 04:45 AM
MollyFoley
Regular Contributor

I would really appreciate if someone could test this and see if they can reproduce the problem I am having. I am working with ArcGIS 10.5 and PyCharm Community Edition 2017.3.3 (the most recent update). 

I have built a script in PyCharm, and I run it inside of PyCharm. I have PyCharm set to the ArcGIS interpreter (C:\Python27\ArcGIS10.5\python.exe) so I have access to the arcpy library. I have taken a snippet of my code and pasted below. I have attached a zip file with a shapefile for you to run it with (you'll have to change the directory of the output shapefile on the crop_intersect line). If you run it in "Run" mode, it should work. If you run it in "Debug" mode WITHOUT any breakpoints, it should also work. 

Now... place a breakpoint at the qh_buffer line. Run it in "debug" mode and step over that line when you get to it. It should break and most likely it will give you an error 000735 about invalid parameters/invalid input. 

Next, remove that breakpoint. Place a new breakpoint further down on the crop_intersect line. Run it in "debug" mode and step over that line when you get to it. It should run successfully to that point and then break giving you an error 000732: Input Features: Dataset #1; #2 does not exist or is not supported.

I have checked and rechecked that these errors are invalid and these datasets are being created/the tools are written with correct syntax so the parameters are valid. I know this is a PyCharm IDE problem because I rolled back to a previous version of PyCharm and can run my script succesfully in debug mode with breakpoints, without throwing illegitimate errors. It also clearly is an IDE problem because there is no reason it should work on "run" mode, "debug" mode without breakpoints, and be able to successfully run through a line that previously caused an error when setting a new breakpoint further down the script, but not be able to run succesfully through debug mode with breakpoints. It is related to the breakpoints somehow.

Can anyone reproduce this so I can be sure 100% sure it's IDE related and has nothing to do with my computer's configuration? Evidence suggests that the problem lies in how the debugger is interacting with the arcpy library, but I have no idea what the problem is beyond that. If anybody has any ideas, I'd love to hear them.

import arcpy, sys

arcpy.env.overwriteOutput = True

svyPtFC = sys.argv[1]

select_query = '"FID" = 9'

qhPolys = arcpy.Select_analysis(svyPtFC, 'in_memory/qhPolys', select_query)
qh_buffer = arcpy.Buffer_analysis(qhPolys, 'in_memory/qh_buffer', '50 
Meters')
cropFID = '"FID" = 1'
cropPoly = arcpy.Select_analysis(svyPtFC, 'in_memory/cropPoly', cropFID)
crop_intersect = arcpy.Intersect_analysis([[cropPoly, 1], [qh_buffer, 2]],
                                      r'C:\Users\xxx\GIS_Testing\crp_int.shp')
feature_count = arcpy.GetCount_management(crop_intersect)
print feature_count‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Tags (2)
0 Kudos
2 Replies
JoshuaBixby
MVP Esteemed Contributor

I haven't had time to test/check, but it seems like you have already isolated the issue, and the issue isn't ArcGIS:

I know this is a PyCharm IDE problem because I rolled back to a previous version of PyCharm and can run my script succesfully in debug mode with breakpoints, without throwing illegitimate errors.

Have you reached out to JetBrains, either their technical support or PyCharm forum?

MollyFoley
Regular Contributor

I haven't reached out to them yet, mostly because it's unlikely they have a GIS person on staff that will be able to reproduce the error since it's specifically an error that occurs with the arcpy library. I have seen no reports of the debugger being faulty with other libraries (yet). I will follow up there shortly, but I'd really like to know if this can be reproduced by someone who uses arpcy.

0 Kudos