PythonWin + ArcGIS not playing well together.

2692
9
01-17-2012 04:46 AM
LT
by
Occasional Contributor
Is anyone else having problems with PythonWin running geoprocessing commands?  Pythonwin intermittently crashes on arcpy.env.workspace, arcpy.Buffer, or other tools.  Has anyone solved this issue yet? Here's a video to show you what I mean:

http://screencast.com/t/EbXKrGP6H

In the video, closing PythonWin between each test:
test 1: run script (with running man) -- it crashes
test 2: run script with step through -- it works
test 3: run script with running man -- it works
test 4: comment out setting workspace in script.  run script (with running man) -- it crashes
test 5: workspace still commented out, try our fix in the interactive window -- it crashes when setting workspace
test 6: try same thing -- it crashes
test 7 : try with capital T,  -- it crashes
test 8:  run script with running man -- it crashes
test 9: run script with step over -- it crashes
test 10: add line of code setting workspace back into script.  Run it -- it crashes. (though the vid stops just before this)

I know there are alternatives to Pythonwin.  But I'd really rather solve this problem then march off to a different editor.  I know this stuff can be run at the Python command prompt inside Arc, but that doesn't have the debugging facilities of PythonWin.  IDLE also doesn't have the nice debugging interface of PythonWin.

Thanks!

Here's the code I used in the video. (Though there's nothing wrong with the code itself.)  If anyone would be kind enough to try this out, you can replace the line of code that points to my shapefile with one of your own, and it should work with no arguments.  (input = "C:\\Temp\\COVER63p.shp" )
# ---------------------------------------------------------------------------
# exported2.py
# Created on: 2012-01-10 12:52:28.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: exported2 <distance> <input> <output> 
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy
arcpy.env.overwriteOutput = 1
arcpy.env.workspace = "C:/Temp"
# Script arguments
distance = arcpy.GetParameterAsText(0)
if distance == '#' or not distance:
    distance = "5 Feet" # provide a default value if unspecified

input = arcpy.GetParameterAsText(1)
if input == '#' or not input:
    input = "C:\\Temp\\COVER63p.shp" # provide a default value if unspecified

output = arcpy.GetParameterAsText(2)
if output == '#' or not output:
    output = "C:\\Temp\\abc.shp" # provide a default value if unspecified

# Process: Buffer
arcpy.Buffer_analysis(input, output, distance)

print arcpy.GetMessages()

0 Kudos
9 Replies
DanPatterson_Retired
MVP Emeritus
Did you install Pythonwin using the version from your ArcGIS installation CD?
0 Kudos
LT
by
Occasional Contributor
Hi Dan,

I downloaded PythonWin from Source Forge. 

http://sourceforge.net/projects/pywin32/files/pywin32/Build%20214/

Used this one:  pywin32-214.win32-py2.6.exe

http://screencast.com/t/ppiOhknY

Does the disc contain a different build?  I work at an institution where we have a blanket license, so I don't have a CD.
0 Kudos
DanPatterson_Retired
MVP Emeritus
Search this forum using
Pythonwin installation
as the search entry, some threads may be pertinent to you installation etc.
eg.   http://forums.arcgis.com/threads/33453-Python-amp-PythonWin-default-installation-directory?highlight...
0 Kudos
LT
by
Occasional Contributor
Thanks, Dan.  Most of these suggestions seem to deal with PythonWin installation location and build problems, situations where it either works or doesn't work.  Not ones like mine where it's more like a memory leak, freaky unpredictable behavior, working when the mood strikes it.   I'm really surprised no one else is reporting this problem.
Except perhaps this one person describing the same problem on Devshed:
http://forums.devshed.com/python-programming-11/pythonwin-stops-working-when-assigning-workspace-pat...

I'm wondering if it could be something to do with some of the additional extensions we've installed:

ARCGIS Data Interoperability
ARCGIS DESKTOP VBA Resources for Developers
ARCOBJects SDK for the Microsft .NET Framework

Dan, do you have these installed in your working environment?
0 Kudos
DanPatterson_Retired
MVP Emeritus
Sorry, no I don't.  It is usually the quirky install that does things.  You might want to check out Pyscripter instead, it is pretty nice and I use it in place of Pythonwin many times
http://blogs.esri.com/dev/blogs/geoprocessing/archive/2011/06/17/pyscripter-_2d002d00_-free-python-i...
This will determine whether it is a python or pythonwin if the quirkiness continues.
0 Kudos
LT
by
Occasional Contributor
Hi Dan,

I just tried pyScripter.  It's fantastic.  Thank you for pointing it out!  Only thing so far is no folding.    I think I'm going to convert.  Why do you still you PythonWin sometimes??

By the way, v2.4.3 works for me, but not v2.4.6.  But no sweat.  I'm not that into early adoption.

In the mean time, I think we might have solved our original problem by installing a service pack for the data interoperability extension:
http://resources.arcgis.com/content/patches-and-service-packs?fa=viewPatch&PID=83&MetaID=1787  

Too early to be 100% certain.  Will test it on other machines, but I think that may have been it.
0 Kudos
EmilyHimmelstoss
New Contributor
I am new to Python and in the process of taking the "Python Scripting for Geoprocessing Workflows" online course.  I am at Service Pack 3 and this is still an issue.  Any time I attempt to run my script (either the one I wrote during the course exercise or the one provided as part of the exercise materials) PythonWin crashes.  I can successfully run the script in IDLE, and often have success running it line by line within the Interactive Window of PythonWin, but more often than not the program crashes. 

I plan to check out PyScripter now so that I can continue with the course, but wanted to post since I too have this problem and it was not resolved with Service Pack updates.
0 Kudos
LT
by
Occasional Contributor
ehimmelstoss,

I had really fluky problems with Python when I was using Arc 10 until I installed a service pack that seemed entirely unrelated.  It was the 'Data Interoperability' service pack.   Try it, if you haven't already.  I haven't had any problems with Python and Arc10.1, so get 10.1 if you can.
0 Kudos
SianDoherty
New Contributor II
ehimmelstoss,

I had really fluky problems with Python when I was using Arc 10 until I installed a service pack that seemed entirely unrelated.  It was the 'Data Interoperability' service pack.   Try it, if you haven't already.  I haven't had any problems with Python and Arc10.1, so get 10.1 if you can.


I realise this is many months old and that i'm hijacking the thread but I had been having problems with PythonWin - would just close on any script execution.
I tried the patch for the Data Interoperability Extension and voila, now it executes scripts like it should.
Thanks for the suggestions.
0 Kudos