I'm using ArcGIS Pro 3.02 and Python 3.9 to create a feature layer and save the layer to a lyrx file. This generates an invalid file error message ("The selected layer file is not valid") when I attempt to add the lyrx to a map. Results are the same whether I run it as a stand-alone script or from the Python window in Pro.
This is the code:
# input polygon feature class
infeatures = "E:\\_Projects\\sample.gdb\\test"
maplayer = 'test'
layerfile = "E:\\Layers\\Test.lyrx"
arcpy.management.MakeFeatureLayer(infeatures, maplayer)
arcpy.management.SaveToLayerFile(maplayer, layerfile, 'ABSOLUTE')
Thank you,
Pam