<?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 Python script with project pathname does not do anything in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/python-script-with-project-pathname-does-not-do/m-p/1246142#M6453</link>
    <description>&lt;P&gt;I have several python scripts that I would like to have run outside of ArcGIS Pro. Its mainly to export map series weekly without having to manually open the project. I keep hitting a dead end because most of my python scripts do nothing even when ran in the project if I set&amp;nbsp;arcpy.mp.ArcGISProject to reference the path of the project. All of my scripts work if I change the pathname to ("Current") but obviously that can't be run outside of Pro. Here are two samples of python scripts I am trying to get to work.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;##  BLOCK DETAILS TO BLOCK NAMES ##
aprx = arcpy.mp.ArcGISProject("C:\\GIS Local Directory\\RanchMaps.aprx")
for m in aprx.listMaps("Default Map"):
   lyr = m.listLayers("Block Boundary")[0]
   z = ["default"], ["details open"], ["Ranches Zoomed In"], ["Center Unlocked"], ["Center Locked"], ["Center Left Locked"]
   for i in z:
      if lyr.supports("SHOWLABELS"):
         lblClass = lyr.listLabelClasses(i[0])[0]
         lblClass.visible = False
      if lyr.supports("SHOWLABELS"):
         lblClass = lyr.listLabelClasses("block name")[0]
         lblClass.visible = True


import arcpy
aprx = arcpy.mp.ArcGISProject("C:\\GIS Local Directory\\RanchMaps.aprx")
m = aprx.listMaps("Default Map")[0]
lyrList = m.listLayers()
for lyr in lyrList:
  if lyr.longName == "Ranches (Sun Pacific)\\Block Details":
    lyr.visible = False
  if lyr.longName == "Ranches (Sun Pacific)\\Block Names":
    lyr.visible = True
aprx.save()
del aprx&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again they both work as intended if I change the project path name to ("CURRENT")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jan 2023 19:10:59 GMT</pubDate>
    <dc:creator>chill_gis_dude</dc:creator>
    <dc:date>2023-01-06T19:10:59Z</dc:date>
    <item>
      <title>Python script with project pathname does not do anything</title>
      <link>https://community.esri.com/t5/developers-questions/python-script-with-project-pathname-does-not-do/m-p/1246142#M6453</link>
      <description>&lt;P&gt;I have several python scripts that I would like to have run outside of ArcGIS Pro. Its mainly to export map series weekly without having to manually open the project. I keep hitting a dead end because most of my python scripts do nothing even when ran in the project if I set&amp;nbsp;arcpy.mp.ArcGISProject to reference the path of the project. All of my scripts work if I change the pathname to ("Current") but obviously that can't be run outside of Pro. Here are two samples of python scripts I am trying to get to work.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;##  BLOCK DETAILS TO BLOCK NAMES ##
aprx = arcpy.mp.ArcGISProject("C:\\GIS Local Directory\\RanchMaps.aprx")
for m in aprx.listMaps("Default Map"):
   lyr = m.listLayers("Block Boundary")[0]
   z = ["default"], ["details open"], ["Ranches Zoomed In"], ["Center Unlocked"], ["Center Locked"], ["Center Left Locked"]
   for i in z:
      if lyr.supports("SHOWLABELS"):
         lblClass = lyr.listLabelClasses(i[0])[0]
         lblClass.visible = False
      if lyr.supports("SHOWLABELS"):
         lblClass = lyr.listLabelClasses("block name")[0]
         lblClass.visible = True


import arcpy
aprx = arcpy.mp.ArcGISProject("C:\\GIS Local Directory\\RanchMaps.aprx")
m = aprx.listMaps("Default Map")[0]
lyrList = m.listLayers()
for lyr in lyrList:
  if lyr.longName == "Ranches (Sun Pacific)\\Block Details":
    lyr.visible = False
  if lyr.longName == "Ranches (Sun Pacific)\\Block Names":
    lyr.visible = True
aprx.save()
del aprx&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again they both work as intended if I change the project path name to ("CURRENT")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 19:10:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/python-script-with-project-pathname-does-not-do/m-p/1246142#M6453</guid>
      <dc:creator>chill_gis_dude</dc:creator>
      <dc:date>2023-01-06T19:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python script with project pathname does not do anything</title>
      <link>https://community.esri.com/t5/developers-questions/python-script-with-project-pathname-does-not-do/m-p/1252650#M6480</link>
      <description>&lt;P&gt;The following bit of code worked for me, I ran it from the IDE spyder:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
aprx = arcpy.mp.ArcGISProject(r"C:\Scratch\test\test.aprx")
m = aprx.listMaps("Map3")[0]
lyrList = m.listLayers()
for lyr in lyrList:
    if lyr.longName == "Source Nodes":
        lyr.visible = True
aprx.save()
print("Done!")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You should not have ArcPro open as that will surely file lock the project. How are you running your external scripts? Are you running them from an IDE or are they scheduled by Windows? I think the source of your problem lies elsewhere not in the code itself?&lt;/P&gt;</description>
      <pubDate>Sat, 28 Jan 2023 23:17:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/python-script-with-project-pathname-does-not-do/m-p/1252650#M6480</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2023-01-28T23:17:35Z</dc:date>
    </item>
  </channel>
</rss>

