I am using arcpy in arcgis pro 2.9. I got a python toolbox built that has a input for a shapefile layer, it works if user has loaded that shapefile into map and select it from drop down in the parameter list. But is there a way to just open that shapefile from file path directly? I've searched for quite a while, didn't find anything to do that.
At this point, that python toolbox would use arcpy.GetParameter(0) to get that layer object, I would really need a way to just get that layer object from shapefile path, e.g. C:\test\data\myshapefile.shp
I believe that the solution is to use
arcpy.MakeFeatureLayer_managementandarcpy.mapping.LayerSee example below - I can't test at the moment, but worth a try.