I have wrote the following script to update the locations of the ArcGIS Pro
import arcpy, os
aprx = arcpy.mp.ArcGISProject('current')
lyrFolder = "Z:\\ArcGIS_PRO_Migration\\layerfiles\\"
listFC = aprx.listBrokenDataSources()
for fc in listFC:
lyrFC = str(fc) + (".lyrx")
lyrfile = os.path.join(lyrFolder, lyrFC)
When I go to run it I get the following error
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\utils.py", line 191, in fn_
return fn(*args, **kw)
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\_mp.py", line 1289, in addLayer
return convertArcObjectToPythonObject(self._arc_object.addLayer(*gp_fixargs((add_layer_or_layerfile, add_position), True)))
However, I have created the layer file and it does exist. What is going on with the script? Is there something I need to improve on or does ArcGIS pro not replace layers automatically. Also I have tried the replace layers knowledge base and it does not replace any layers.