2

EDIT: I rolled back PyCharm versions and it's working again. CLEARLY an IDE issue, not a script issue now. PyCharm version 2017.2.4 is what I rolled back to.

So I have a script that's been working great for me, until today. For some reason, the script will run fine with no errors at all, as long as I don't use PyCharm (Community Edition 2017.3.3) in debugging mode. I need to use debugger, so when it throws errors for no reason and stops the script, it makes it a pointless IDE.

The reason I know this is a PyCharm problem is because I copied the entire script into a different IDE (Wing), set to the same python interpreter, and went through it in debug mode there and it worked fine, no errors.

I have done extensive error testing to make sure the errors aren't actually there in my script; they're not. The script should work as written. It keeps saying datasets don't exist or input features for arcpy tools (a spatial program that hooks into python via a library called "arcpy") don't have values when they do. It's not a script problem, it's an IDE problem.

Has anybody encountered this and know how to fix it?

I do not have any specific environment settings, I just popped an ArcGIS python interpreter in there for the project so I could have access to the arcpy library and that's it. It should be noted that this interpreter is python 2.7 because ArcGIS is not yet compatible with python 3+. I doubt that has anything to do with it, but you never know...

This is a chunk of script causing the issues (if you don't have/know how to use ArcGIS don't bother trying to run it, it won't work for you). What I want to point out is that if I put a breakpoint at the qh_buffer line, it will break after trying to run that line with an arcpy error message that states invalid input/parameters (they are not invalid, it's written exactly how it should be and I have checked that qhPolys is being created and exists). THEN, if I move the breakpoint to the crop_intersect line and run it in debug, it runs through the entire code, INCLUDING the buffer statement, but then errors out with error 000732 "Input Features: Dataset #1; #2 does not exist or is not supported" (they both do exist, because I have hardcoded them to an output directory before and they are created just fine).

import arcpy

arcpy.env.overwriteOutput = True

svyPtFC = r"C:\Users\xxx\GIS_Testing\Crop_Test.shp"

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

It does not make sense that it can cause an error at the buffer line if I put a breakpoint near there, but then if I move the breakpoint further down, that line will run fine and it'll just break at the next breakpoint... does explain why it works when you just hit "Run" instead of doing debug mode though. No breakpoints!

9
  • 1
    The most important thing is missing: the errors and their stacktraces. Commented Jan 23, 2018 at 20:37
  • @CristiFati - They are not PyCharm errors. If you do not work with ArcPy you will not understand the errors so they're a bit irrelevant to my post, but I understand why you asked for them. They are errors sent by the software program because an arcpy tool failed. For instance, one of them is "Error 000732: Input Features: Dataset #1; #2 does not exist or is not supported" (they do exist and they are supported). Despite the errors being ArcPy errors, it is a problem with the IDE because I can run this script elsewhere and it works as expected. I can even run it in PyCharm if not in debug mode. Commented Jan 23, 2018 at 20:53
  • 1
    Hmm, it might have smth to do with the way that Pycharm calls its debugger (pydevd.py) which might conflict with the other tool. Try running it with/without debug get the 1st lines from the Pycharm console (that is the cmdline) and do some comparisons. Commented Jan 23, 2018 at 20:58
  • @CristiFati - Possibly, though aside from the pyded.py being called with some extra flags (--multiproc --qt-support = auto --client 127.0.0.1 --port 5727) I'm not seeing much difference. The problem seems to stem from the breakpoints; it runs successfully in "Run" mode and "Debug" mode as long as when in debug mode there are zero breakpoints (which kinda defeats the purpose of debug). Commented Jan 23, 2018 at 21:08
  • Cross-posted as gis.stackexchange.com/q/268973/115 Commented Jan 24, 2018 at 4:27

1 Answer 1

2

disabling cython speedups by adding PYDEVD_USE_CYTHON=NO environment variable to the run/debug configuration helped in my case (as suggested here)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.