AnsweredAssumed Answered

Python Error

Question asked by anthony.corcoran.sweco on Feb 12, 2019
Latest reply on Feb 12, 2019 by bixb0012

Im receiving this error for a script that is trying to change selected string within a .shp file path.


Any suggestion on the error.arcpy


Runtime error 
Traceback (most recent call last):
File "<string>", line 6, in <module>
File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\", line 182, in fn_
return fn(*args, **kw)
File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\", line 697, in findAndReplaceWorkspacePath
return convertArcObjectToPythonObject(self._arc_object.findAndReplaceWorkspacePath(*gp_fixargs((find_workspace_path, replace_workspace_path, validate), True)))
ValueError: Layer: Unexpected error

For the following script.

import arcpy
... mxd = arcpy.mapping.MapDocument(r"H:\GQRA_screening_tool\Arcmap\SwecoTemplate_SI_A3_S2.mxd")
... for lyr in arcpy.mapping.ListLayers(mxd):
... if lyr.supports("DATASOURCE"):
... if r"H:\GQRA_screening_tool\Shapefiles".lower() in lyr.dataSource.lower():
... lyr.findAndReplaceWorkspacePath(r"S1", r"S2")
... mxd.saveACopy(r"H:\GQRA_screening_tool\Arcmap\SwecoTemplate_SI_A3_S2.mxd")
... del mxd