0

I'm new to GIS programming, and am going through the Esri "Getting Started with arcpy.mp" tutorial.

When I try the following:

lyrFile = arcpy.mp.LayerFile(r"path to a layer file") 

I get the following error:

File "", line 1, in File "c:\users\ME\appdata\local\programs\arcgis\pro\Resources\arcpy\arcpy_mp.py", line 773, in init self._arc_object = arcgisscripting._mapping.LayerFile(*gp_fixargs((layer_file_path,), True)) OSError: C:\Users\ME\Documents\ArcGIS\myLayer.lyrx

Typical google search doesn't really bring up much except for Adding feature class to Map in CURRENT project using ArcPy in ArcGIS Pro?

I've tried the alternate methods of adding a Layer file as suggested in the question thread, but get the same OS error.

What is causing this error, so I can figure out how to resolve it?

2

I needed to pay attention to file extensions!

The tutorial assumes you created the layer file in ArcGIS Pro. I was attempting to add a layer created in ArcGIS Desktop 10.5, which has the '.lyr' extension, NOT '.lyrx'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.