Optimum python IDE for debugging?

1354
16
02-28-2013 02:25 AM
JT2
by
New Contributor II
What is ESRI's 'official' stance for which Python environment to debug in? Pythonwin seems to be advocated, but I've noticed there are others such as pyscripter. Which one offers the best debugging environment? And the best intellisense / autocompletion?

I see there is some guidance here http://blogs.esri.com/esri/arcgis/2010/09/14/review-of-ides-for-python/ but I really think that ESRI needs to take a more proactive stance here, because Python adoption is surely premised on the quality of the tools that we can use to debug, which at the moment is nowhere near as easy as say VBA or Visual Studio.
Tags (2)
0 Kudos
16 Replies
DanPatterson_Retired
MVP Emeritus
Each person has their own preferences, however, the quality of the debugging capabilities might depend upon how well one writes code.  Often, Notepad works fine for me.
0 Kudos
JamesCrandall
MVP Frequent Contributor
TextPad for me -- the line and space numbers help with formatting and alignment.

It's been challenging, but not overwhelmingly difficult to adjust --- most of my career has been developing COM/ArcObjects using languages that don't care about formatting and super functional IDE's.
0 Kudos
MaraStoica1
New Contributor
There are some good ones out there if you're willing to spend a little money. PyCharm and WingIDE are the 2 I've heard the best things about. They both have free trials available.

If you want free, I'd recommend PyScripter. It's not as good as the ones mentioned above, but it gets the job done, and it sure beats IDLE
0 Kudos
JohnDye
Occasional Contributor III
PyScripter is the current apple of my eye.
0 Kudos
MarcoBoeringa
MVP Regular Contributor
I have only used it sparingly, but from the different "standard" IDEs I installed and tried, I also found PyScripter one of the more useful ones to work with while debugging. Nice interception and launch of PyScripter once debugging is setup and you try to run a script from ArcGIS that needs debugging.
0 Kudos
JT2
by
New Contributor II
Thanks everyone. I will be sure to check out some of these programs.

So, what is the solution for the annoying problem when debugging in the Python window...when it counts lines by ignoring blank lines, whereas your script editor usually counts line numbers including the blanks? This is a massive usability issue for beginners, when you get a traceback error at line 26 or whatever which doesn't correspond at all to your script in an external editor. Any ideas?
0 Kudos
BradPosthumus
Occasional Contributor II
To answer your original post, sometimes I use Notepad++ but normally I just use PythonWin since it was kind of the default IDE when ESRI brought Python into ArcGIS.  I tried switching to other IDE's but I would always end up reverting back to PythonWin. I've grown to like the simplicity of it. At times I'll drop my scripts into the Ninja IDE for when I want my code to conform to the PEP8 coding style guide. It does a good job of highlighting all of the inconsistencies.

As for your second question, I can't recall ever seeing a traceback with the wrong line number, regardless of the number of blank lines. Where are you seeing this happen?
0 Kudos
JT2
by
New Contributor II
As for your second question, I can't recall ever seeing a traceback with the wrong line number, regardless of the number of blank lines. Where are you seeing this happen?


Thanks for your reply. Well I get this behaviour consistently, and it can make it VERY difficult to debug because the Python window (for me, at least) ignores blank lines.

Here's a sample script:

for i in range(4):
   print i

print "complete" x


As you can see, there are four lines. It's nice to have blank lines because it helps to organise the code.

Naturally there is a deliberate error, and this is what the Python window says:

>>> for i in range(4):
...    print i
... print "complete" x
... 
Parsing error <type 'exceptions.SyntaxError'>: invalid syntax (line 3)


It says the error is on line 3, when we all know it's on line 4. This is because the Python window ignores blank lines, either when you paste them in, or when you right click and choose Load to open a script.

This is the behaviour that troubles me because all correspondence between errors and the original script is lost, and that is a bad thing because it's very hard to count lines in your original script editor. Any solutions?
0 Kudos
MathewCoyle
Frequent Contributor

This is the behaviour that troubles me because all correspondence between errors and the original script is lost, and that is a bad thing because it's very hard to count lines in your original script editor. Any solutions?


Debug in your script editor and not ArcGIS?
0 Kudos