<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Trouble accessing .lyrx in ArcGIS Pro Package commondata folder from script in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/trouble-accessing-lyrx-in-arcgis-pro-package/m-p/867228#M4470</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am building a Task Workflow to automate deployment of Crowdsource Polling. I have a task for creating a feature layer from a spreadsheet that sets up a relationship class between the feature layer and related commenting table. Once this is finished I need to symbolize the layer based on a field in the comment layer. I have created a layer file to accomplish this need by symbolizing based on layer file. I have got this to work before packaging the project but need it to work from within a packaged project. When I use the Package Project tool I have saved a the layer file (.lyrx) using the "additonal files" input:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="490680" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/490680_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This adds the .lyrx into the commondata folder of the package.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My issue is that when I get the path for the .lyrx and plug it into my code I am getting a ValueError. When I do this before packaging the project I do not get a ValueError. I have also tried running the code from the package after I use the extract package tool and get the same error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;p = os.path.dirname(arcpy.mp.ArcGISProject("CURRENT").defaultGeodatabase)
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("Map")[0]
default_gdb = arcpy.mp.ArcGISProject("CURRENT").defaultGeodatabase
rec_sites = os.path.join(default_gdb, "RecSitesXY")

# local layer file path before packaging project
#lf = arcpy.mp.LayerFile(os.path.join(p, "FeeToolRecSiteSymbols.lyrx"))
# pro package layer file


# layer filepath after packaging project
lf = os.path.join(os.path.dirname(p), 'commondata', 'pro-recfeetool-deployment-task-workflow', 'FeeToolRecSiteSymbols.lyrx')

# add coment layer and symbolize using layer file
m.addDataFromPath(rec_sites)

# Using insert layer instead of arcpy.ApplySymbologyFromLayer_management because 
# there is a known bug that this will not work from within a script
m.insertLayer(m.listLayers()[0],lf)

# clean up
m.removeLayer(m.listLayers()[1])
aprx.save()

I have also tried to search for the layer file this way and have tried using the output path with the same error 
&lt;IMG __jive_id="490681" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/490681_pastedImage_3.png" /&gt;

&lt;/PRE&gt;&lt;P&gt;The value error happens at this point in the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;m.insertLayer(m.listLayers()[0],lf)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 17:01:15 GMT</pubDate>
    <dc:creator>ZacharyNeumann1</dc:creator>
    <dc:date>2021-12-12T17:01:15Z</dc:date>
    <item>
      <title>Trouble accessing .lyrx in ArcGIS Pro Package commondata folder from script</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/trouble-accessing-lyrx-in-arcgis-pro-package/m-p/867228#M4470</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am building a Task Workflow to automate deployment of Crowdsource Polling. I have a task for creating a feature layer from a spreadsheet that sets up a relationship class between the feature layer and related commenting table. Once this is finished I need to symbolize the layer based on a field in the comment layer. I have created a layer file to accomplish this need by symbolizing based on layer file. I have got this to work before packaging the project but need it to work from within a packaged project. When I use the Package Project tool I have saved a the layer file (.lyrx) using the "additonal files" input:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="490680" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/490680_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This adds the .lyrx into the commondata folder of the package.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My issue is that when I get the path for the .lyrx and plug it into my code I am getting a ValueError. When I do this before packaging the project I do not get a ValueError. I have also tried running the code from the package after I use the extract package tool and get the same error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;p = os.path.dirname(arcpy.mp.ArcGISProject("CURRENT").defaultGeodatabase)
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("Map")[0]
default_gdb = arcpy.mp.ArcGISProject("CURRENT").defaultGeodatabase
rec_sites = os.path.join(default_gdb, "RecSitesXY")

# local layer file path before packaging project
#lf = arcpy.mp.LayerFile(os.path.join(p, "FeeToolRecSiteSymbols.lyrx"))
# pro package layer file


# layer filepath after packaging project
lf = os.path.join(os.path.dirname(p), 'commondata', 'pro-recfeetool-deployment-task-workflow', 'FeeToolRecSiteSymbols.lyrx')

# add coment layer and symbolize using layer file
m.addDataFromPath(rec_sites)

# Using insert layer instead of arcpy.ApplySymbologyFromLayer_management because 
# there is a known bug that this will not work from within a script
m.insertLayer(m.listLayers()[0],lf)

# clean up
m.removeLayer(m.listLayers()[1])
aprx.save()

I have also tried to search for the layer file this way and have tried using the output path with the same error 
&lt;IMG __jive_id="490681" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/490681_pastedImage_3.png" /&gt;

&lt;/PRE&gt;&lt;P&gt;The value error happens at this point in the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;m.insertLayer(m.listLayers()[0],lf)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 17:01:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/trouble-accessing-lyrx-in-arcgis-pro-package/m-p/867228#M4470</guid>
      <dc:creator>ZacharyNeumann1</dc:creator>
      <dc:date>2021-12-12T17:01:15Z</dc:date>
    </item>
  </channel>
</rss>

