Hi Folks,
In ArcGIS Pro 2.4.0, I noticed some unexpected behavior with forward slashes in data paths with code run in the Python console embedded in Pro.
In short, if backslashes are used, the code works:
d = "C:\gispy\data\ch02\park.shp"
proj = arcpy.mp.ArcGISProject("CURRENT")
m = proj.listMaps()[0]
m.addDataFromPath(d)
<arcpy._mp.Layer object at 0x00000287876AE7F0>
# Hurray! Data added to map.
But if forward slashes are used in the data path, it throws a RuntimError and fails to add data to the map:
d2 = "C:/gispy/data/ch02/park.shp"
m.addDataFromPath(d2)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\_mp.py", line 1531, in addDataFromPath
return convertArcObjectToPythonObject(self._arc_object.addDataFromPath(*gp_fixargs((data_path,), True)))
RuntimeError
I could not find a bug report on this. Are there plans to address this or is this intentional behavior? If so, why?