Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Similar to Enumeration Problem with Eclipse and ArcGis 9.3, with Arcgis v10 I no longer seem to be able to run python scripts from a command shell. Entering the same code into an interactive python console from the same shell does work! Other scripts I have from a few months ago seem to work fine. I don't get it.

This works:

d:\s>python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import arcpy
>>> arcpy.env.workspace = 'd:/'
>>> print arcpy.env.workspace
d:/
>>>

Create a minimal test file:

d:\s>copy con d:\code\arcgis\test-arcpy.py
import arcpy
arcpy.env.workspace = 'd:/'
print "Workspace is: ", arcpy.env.workspace^Z
        1 file(s) copied.

and give it a spin:

d:\s>python d:\code\arcgis\test-arcpy.py
Traceback (most recent call last):
  File "d:\code\arcgis\test-arcpy.py", line 1, in <module>
    import arcpy
  File "C:\ESRI\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 17, in <module>
    from geoprocessing import gp
  File "C:\ESRI\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>
    from _base import *
  File "C:\ESRI\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 568, in <module>
    env = GPEnvironments(gp)
  File "C:\ESRI\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 565, in GPEnvironments
    return GPEnvironment(geoprocessor)
  File "C:\ESRI\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 521, in __init__
    self._refresh()
  File "C:\ESRI\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 523, in _refresh
    envset = (set(env for env in self._gp.listEnvironments()))
  File "C:\ESRI\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 523, in <genexpr>
    envset = (set(env for env in self._gp.listEnvironments()))
  File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 246, in __getitem__
    raise TypeError("This object does not support enumeration")
TypeError: This object does not support enumeration

update it's directory specific! If I copy that same test-arcpy.py file somewhere else it works.

share|improve this question
    
Do you have two copies of Python installed? I had weird problems associated with PythonX,Y (gis.stackexchange.com/questions/8324/…) which were resolved when I installed ArcGIS 10 without the built-in python package. –  Jason Feb 2 '12 at 18:13
    
found it @Jason, see below. –  matt wilkie Feb 2 '12 at 18:36

1 Answer 1

up vote 4 down vote accepted

Aahhhh, found it! I ran afoul of keeping scripts I wrote for Arcgis 9 and 10 in the same directory. Something about the initialization logic in import arcpy finds the custom arcgisscripting.py used for running python 2.6 with arcgis 9.3 when they are located together.

So as long as I keep them separated all is copacetic. I didn't run into this earlier because my other v10 scripts are part of a v10 specific project stored in a different spot.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.