Menu

#506 "This object does not support enumeration"

open
nobody
win32 (141)
5
2010-09-27
2010-09-27
matt wilkie
No

I have script which works fine with python 2.5, but in 2.6 raises error below. The script can be nabbed from http://code.google.com/p/maphew/source/browse/trunk/gis/list-fc-aliases.py. Unfortunately the script requires ArcGIS 9.3 installed on the host machine, along with arcgisscripting.py from here (http://www.yukongis.ca/How_To/Upgrading_ArcGIS_Python) plunked into C:\Python2.6\Lib\site-packages, so duplicating it is not easy.

I'm hoping that someone just eyeballing the code can tell me what's wrong?
Thanks

{{{
Traceback (most recent call last):
File "list-fc-aliases.py", line 40, in <module>
getDataSets()
File "list-fc-aliases.py", line 17, in getDataSets
for fd in fds:
File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 242, in
__getitem__
raise TypeError("This object does not support enumeration")
TypeError: This object does not support enumeration
}}}

Discussion

  • matt wilkie

    matt wilkie - 2010-09-27

    works on py2.5, not in py2.6

     
  • Mark Hammond

    Mark Hammond - 2010-09-27

    Is it possible you need to run 'makepy' in 2.6? This could happen if 2.5 had makepy support generated but 2,6 did not (or vice versa). Assuming the same pywin32 version with both, that is the only thing I can think of.

     
  • matt wilkie

    matt wilkie - 2010-09-27

    hmmm, I've never used makepy before. When I run it here there are about a hundred ArcGIS (actually "ESRI") type libraries available. I suppose I need to find which particular one is being called by gp.ListDatasets and run makepy on that?

     
  • Mark Hammond

    Mark Hammond - 2010-09-27

    Or try replacing your call to win32com.client.Dispatch with win32com.gencache.EnsureDispatch - the latter should magically run makepy when necessary.

     
  • matt wilkie

    matt wilkie - 2010-09-27

    With that I'm told gencache doesn't exist. I'm using pywin32 build 214.

    {{{
    PythonWin 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on win32.
    Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information.
    Traceback (most recent call last):
    File "C:\Python26\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 322, in RunScript
    debugger.run(codeObject, __main__.__dict__, start_stepping=0)
    File "C:\Python26\Lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 60, in run
    _GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
    File "C:\Python26\Lib\site-packages\Pythonwin\pywin\debugger\debugger.py", line 655, in run
    exec cmd in globals, locals
    File "C:\Python26\Lib\site-packages\arcgisscripting.py", line 67, in <module>
    gp=create()
    File "C:\Python26\Lib\site-packages\arcgisscripting.py", line 47, in create
    gp = win32com.gencache.EnsureDispatch("esriGeoprocessing.GpDispatch.1")
    AttributeError: 'module' object has no attribute 'gencache'
    }}}

     
  • Mark Hammond

    Mark Hammond - 2010-09-27

    Sorry - I meant win32com.client.gencache - you need to import it first.

     
  • matt wilkie

    matt wilkie - 2010-09-28

    minimal test script and results showing broken gencache.EnsureDispatch

     
  • matt wilkie

    matt wilkie - 2010-09-28

    okay, I tried that and observe new files and directories created under ./site-packages/win32com/gen_py/ however this breaks other things. I have to delete the contents of gen_py to get any arcgisscripting calls to work again, even using the old method of creating the dispatch object.

    Attached is a test script and the results on my system. The gen_py dir is copied from site-packages after using win32com.client.gencache.EnsureDispatch.

    In the PythonWin interactive shell typing gp.<something> still shows up the objects which are later said not to exist (see sreenshot).