I am trying to upgrade an arcpy script written for ArcGIS Desktop to support ArcGIS Pro (2.9.4).
The script needs to open an old-style .lyr file (not .lyrx), and then perform various operations on layers in that file.
For ArcGIS Desktop I did this:
lyr_file = arcpy.mapping.Layer(lyr_filename)
The above command worked as expected in arcpy for ArcGIS Desktop.
With ArcGIS Pro I am doing this:
lyr_file = arcpy.mp.LayerFile(lyr_filename)
The call to arcpy.mp.LayerFile(..) hangs and seems to never return. It's unclear to me why the function hangs. One guess is that it's related to the fact that the .lyr file I am trying to access does not have data source connection info embedded. (One of my goals is to set connection information after I open the file.) Missing connection info wasn't a problem in ArcGIS Desktop, but perhaps it's a problem ArcGIS Pro??
Sample script:
import arcpy
layer_filename = r"..." #path to .lyr file without connection info embedded
print("the following function call never returns")
lyr_file = arcpy.mp.LayerFile(layer_filename)
print("this line is never reached")
Any suggestions would be appreciated!