hi, i'm from Peru, so my english is really bad, but anyway.

I got this code

import win32com.client, sys, os
gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")

#Configura el directorio de trabajo
gp.workspace = "E:/PRACTICANTES/erich/python/NameMatching.mdb"

#Lista de features
listaFC = gp.ListFeatureClasses("*")
#Loop para listar los features
listaFC.Reset()
fc = listaFC.Next()
while fc:
   if fc == "cp06wFC":
       print "Trabajamos con " + fc
       ruta = gp.workspace + "/" + fc
       #Loop para listar los campos
       fCampos = gp.ListFields(ruta)
       fCampo = fCampos.next()
       fNomField = "MATCHING"
       fExiste = 0
       while fCampo:
           print fCampo.name + " es tipo " + fCampo.type
           if fCampo.name == fNomField:
               print "El campo " + fNomField + " ya fue creado"
               fExiste = 1
           fCampo = fCampos.next()
       if fExiste == 0:
           print fExiste
           gp.AddField(fc, fNomField, "text", "30")
       #Crea un Search Cursor para este Feature
#        fFilas = gp.SearchCursor(ruta)
       fFilas = gp.UpdateCursor(ruta)
       #Loop para listar los registros
       fFilas.Reset()
       fFila = fFilas.Next()
       while fFila:
           fUBIGEO = fFila.getvalue("UBIGEO")
           fNomCP = fFila.getvalue("NOMCP")
           fVlen = len(fFila.getvalue("NOMCP"))
           n = 0
           m = 0
           vNewCode = fNomCP[n]
           print fVlen
           while n < fVlen:
               if fVlen >= 2:
                   if fNomCP[n] == " ":
                      if fNomCP[n+1] == "/":
                         break
                      else:
                          vNewCode = vNewCode + str(m) + fNomCP[n+1]
                          m = -1
               n = n + 1
               m = m + 1
           vNewCode = fUBIGEO + str(n) + vNewCode + str(m)
           print fNomCP.encode('latin-1') + " = " + vNewCode.encode
('latin-1')
           fFila.setvalue(fNomField, vNewCode)
           fFilas.UpdateRow(fFila)
           fFila = fFilas.Next()
   else:
       print "Paso de " + fc
   fc = listaFC.Next()
print "FIN"



that run wihtout problems.

but when I change of computer the same code

apear this

Traceback (most recent call last):
 File "E:\PRACTICANTES\erich\python\python\namematchingV3.py", line 2, in ?
   gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
 File "C:\Python21\win32com\client\__init__.py", line 95, in Dispatch
   dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
 File "C:\Python21\win32com\client\dynamic.py", line 84, in
_GetGoodDispatchAndUserName
   return (_GetGoodDispatch(IDispatch, clsctx), userName)
 File "C:\Python21\win32com\client\dynamic.py", line 72, in
_GetGoodDispatch
   IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
com_error: (-2147024770, 'The specified module could not be found.', None,
None)



I don't know what to do.

I apreciate the help that can bring me =)
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to