<?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 Re: Run standalone python script outside Arc Pro 2.9 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1312727#M68268</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/453586"&gt;@DennisWarnat90&lt;/a&gt;&amp;nbsp;I'm wondering if you ever got this working with SINGLE_LAYER?&lt;/P&gt;&lt;P&gt;I am doing something very similar, having published a python toolbox as a Geoprocessing service. The service is running perfectly fine and all the other functions of it work as expected (exporting data from the map etc). One component that is not working is the same example you posted which is the call to&amp;nbsp;&lt;SPAN&gt;ConvertLabelsToAnnotation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;From what I can tell this does not appear to work when run within the context of a geoprocessing service (or standalone in your case).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;From within Pro and using the same aprx file I can execute python commands to generate successfully with the SINGLE_LAYER option, however when run from within a SOC process as a geoprocessing service the tool generates this message (which i suspect is what you might also have seen if you added some debug output via arcpy.AddMessage(arcpy.GetMessages())):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Start Time: Thursday, July 27, 2023 9:46:14 AM&amp;nbsp;&lt;STRONG&gt;WARNING 002847: No labels to convert. There are no feature layers that are labeled at the conversion scale&lt;/STRONG&gt;. Succeeded at Thursday, July 27, 2023 9:46:16 AM (Elapsed Time: 2.25 seconds)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The layer in question is visible, has labelling turned on and has no scale restriction value that impedes the generation of a label at the map scale I am asking (and which works perfectly with the exact same values when run from within Pro).&amp;nbsp;&lt;/P&gt;&lt;P&gt;When ALL_LAYERS is used for 'which_layers' it does generate but this is not what I need.&lt;/P&gt;&lt;P&gt;I have spun my wheels a lot on this, trying various things and testing in Pro and Enterprise. I feel like it is somehow tied to the fact that when opening the aprx from the Enterprise service context there is no active map (even though the aprx is saved with one). Asking for the activeMap from the ProProject gives None unlike when using from CURRENT within a Pro context. Instead I have to use listMaps()[0].&lt;/P&gt;&lt;P&gt;I'm probably at the point of raising a support issue but just wanted to ask here before I do.&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Jul 2023 18:21:22 GMT</pubDate>
    <dc:creator>MarkReddick</dc:creator>
    <dc:date>2023-07-27T18:21:22Z</dc:date>
    <item>
      <title>Run standalone python script outside Arc Pro 2.9</title>
      <link>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1232628#M66091</link>
      <description>&lt;P&gt;I just want to run a py script standalone e.g. as a batchfile outside of pro.&lt;/P&gt;&lt;P&gt;Exported a model to py script. Doesn´t run outside of Pro. Adjusted File paths but it didn´t run anyway.&lt;/P&gt;&lt;P&gt;No python Pro. (Use IDLE to run script - no error message but no feature class was created)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="py.JPG" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/56187i841EAFFBBD17D78F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="py.JPG" alt="py.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 10:54:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1232628#M66091</guid>
      <dc:creator>DennisWarnat90</dc:creator>
      <dc:date>2022-11-17T10:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Run standalone python script outside Arc Pro 2.9</title>
      <link>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1232646#M66092</link>
      <description>&lt;P&gt;Could you copy the code to make it readable&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633" target="_blank"&gt;Code formatting ... the Community Version - Esri Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 12:04:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1232646#M66092</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-11-17T12:04:38Z</dc:date>
    </item>
    <item>
      <title>Re: Run standalone python script outside Arc Pro 2.9</title>
      <link>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1232648#M66093</link>
      <description>&lt;P&gt;# -*- coding: utf-8 -*-&lt;BR /&gt;"""&lt;BR /&gt;Generated by ArcGIS ModelBuilder on : 2022-11-14 15:41:07&lt;BR /&gt;"""&lt;BR /&gt;import arcpy&lt;/P&gt;&lt;P&gt;def Anno_FIM(): # Anno_FIM&lt;/P&gt;&lt;P&gt;# To allow overwriting outputs change overwriteOutput option to True.&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;Eingabekarte = "G:\\Projekte\\Test_GIS_Projekte\\Friedhofskataster\\FIM_WebOffice\\Friedhofskataster.mapx"&lt;BR /&gt;FIM_2022_gdb_2_ = "G:\\Projekte\\Friedhofskataster\\FIM_2022\\FIM_2022.gdb"&lt;BR /&gt;Beschriftung_Urnengraeber_anonym_2_ = "G:\\Projekte\\Test_GIS_Projekte\\Friedhofskataster\\FIM_WebOffice\\Beschriftung Urnengraeber.lyrx"&lt;BR /&gt;directory2 = "G:\\Projekte\\Friedhofskataster\\FIM_2022\\FIM_2022.gdb"&lt;BR /&gt;&lt;BR /&gt;# Process: Beschriftungen in Annotation konvertieren (Beschriftungen in Annotation konvertieren) (cartography)&lt;BR /&gt;Beschriftung_Urnengraeber_anonym = directory2 + "Beschriftung Urnengraeber_anonym"&lt;BR /&gt;FIM_2022_gdb = arcpy.cartography.ConvertLabelsToAnnotation(input_map=Eingabekarte,&lt;BR /&gt;conversion_scale=100,&lt;BR /&gt;output_geodatabase=FIM_2022_gdb_2_,&lt;BR /&gt;anno_suffix="Annotation", extent="DEFAULT",&lt;BR /&gt;generate_unplaced="ONLY_PLACED",&lt;BR /&gt;require_symbol_id="NO_REQUIRE_ID",&lt;BR /&gt;feature_linked="STANDARD",&lt;BR /&gt;auto_create="AUTO_CREATE",&lt;BR /&gt;update_on_shape_change="SHAPE_UPDATE",&lt;BR /&gt;output_group_layer=Beschriftung_Urnengraeber_anonym,&lt;BR /&gt;which_layers="SINGLE_LAYER",&lt;BR /&gt;single_layer=Beschriftung_Urnengraeber_anonym_2_,&lt;BR /&gt;multiple_feature_classes="FEATURE_CLASS_PER_FEATURE_LAYER",&lt;BR /&gt;merge_label_classes="NO_MERGE_LABEL_CLASS")[0]&lt;/P&gt;&lt;P&gt;if __name__ == '__main__':&lt;BR /&gt;# Global Environment settings&lt;BR /&gt;with arcpy.EnvManager(scratchWorkspace=r"G:\Projekte\Test_GIS_Projekte\Friedhofskataster\FIM_WebOffice\FIM_WebOffice.gdb",&lt;BR /&gt;workspace=r"G:\Projekte\Test_GIS_Projekte\Friedhofskataster\FIM_WebOffice\FIM_WebOffice.gdb"):&lt;BR /&gt;Anno_FIM()&lt;/P&gt;&lt;P&gt;try:&lt;BR /&gt;input("Press enter to continue")&lt;BR /&gt;except SyntaxError:&lt;BR /&gt;input("SythaxError")&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;&lt;P&gt;And this one was created by the model builder:&lt;/P&gt;&lt;P&gt;# -*- coding: utf-8 -*-&lt;BR /&gt;"""&lt;BR /&gt;Generated by ArcGIS ModelBuilder on : 2022-11-17 12:10:14&lt;BR /&gt;"""&lt;BR /&gt;import arcpy&lt;/P&gt;&lt;P&gt;def Anno_FIM(): # Anno_FIM&lt;/P&gt;&lt;P&gt;# To allow overwriting outputs change overwriteOutput option to True.&lt;BR /&gt;arcpy.env.overwriteOutput = False&lt;/P&gt;&lt;P&gt;Eingabekarte = "Friedhofskataster"&lt;BR /&gt;FIM_2022_gdb_2_ = "G:\\Projekte\\Friedhofskataster\\FIM_2022\\FIM_2022.gdb"&lt;BR /&gt;Beschriftung_Urnengraeber_anonym_2_ = "Beschriftung Graeber\\Beschriftung Urnengraeber_anonym"&lt;/P&gt;&lt;P&gt;# Process: Beschriftungen in Annotation konvertieren (Beschriftungen in Annotation konvertieren) (cartography)&lt;BR /&gt;Beschriftung_Urnengraeber_anonym = "Beschriftung Urnengraeber_anonym"&lt;BR /&gt;FIM_2022_gdb = arcpy.cartography.ConvertLabelsToAnnotation(input_map=Eingabekarte, conversion_scale=100, output_geodatabase=FIM_2022_gdb_2_, anno_suffix="Annotation", extent="DEFAULT", generate_unplaced="ONLY_PLACED", require_symbol_id="NO_REQUIRE_ID", feature_linked="STANDARD", auto_create="AUTO_CREATE", update_on_shape_change="SHAPE_UPDATE", output_group_layer=Beschriftung_Urnengraeber_anonym, which_layers="SINGLE_LAYER", single_layer=Beschriftung_Urnengraeber_anonym_2_, multiple_feature_classes="FEATURE_CLASS_PER_FEATURE_LAYER", merge_label_classes="NO_MERGE_LABEL_CLASS")[0]&lt;/P&gt;&lt;P&gt;if __name__ == '__main__':&lt;BR /&gt;# Global Environment settings&lt;BR /&gt;with arcpy.EnvManager(scratchWorkspace=r"G:\Projekte\Test_GIS_Projekte\Friedhofskataster\FIM_WebOffice\FIM_WebOffice.gdb", workspace=r"G:\Projekte\Test_GIS_Projekte\Friedhofskataster\FIM_WebOffice\FIM_WebOffice.gdb"):&lt;BR /&gt;Anno_FIM()&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 12:12:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1232648#M66093</guid>
      <dc:creator>DennisWarnat90</dc:creator>
      <dc:date>2022-11-17T12:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Run standalone python script outside Arc Pro 2.9</title>
      <link>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1233004#M66102</link>
      <description>&lt;P&gt;It's not clear which Python environment you are running the script under in your bat file. You are using arcpy which is a licenced python module, so the script can only run with arcgis pro installed and the right pro python activated (or arcgis enterprise), check out this page to make sure your bat file is setup correctly&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/using-conda-with-arcgis-pro.htm" target="_blank"&gt;Run stand-alone scripts—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When creating posts there is an option to add text as script this is&amp;nbsp;under expand toolbar &amp;gt; Insert/edit code sample, just makes it easier for people to read. You can also run your bat file in the cmd window (navigate to the bat file location in cmd) that way you can see error messages and post them here, you'll get more help that way.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 22:32:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1233004#M66102</guid>
      <dc:creator>graeme_hill</dc:creator>
      <dc:date>2022-11-17T22:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Run standalone python script outside Arc Pro 2.9</title>
      <link>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1312727#M68268</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/453586"&gt;@DennisWarnat90&lt;/a&gt;&amp;nbsp;I'm wondering if you ever got this working with SINGLE_LAYER?&lt;/P&gt;&lt;P&gt;I am doing something very similar, having published a python toolbox as a Geoprocessing service. The service is running perfectly fine and all the other functions of it work as expected (exporting data from the map etc). One component that is not working is the same example you posted which is the call to&amp;nbsp;&lt;SPAN&gt;ConvertLabelsToAnnotation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;From what I can tell this does not appear to work when run within the context of a geoprocessing service (or standalone in your case).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;From within Pro and using the same aprx file I can execute python commands to generate successfully with the SINGLE_LAYER option, however when run from within a SOC process as a geoprocessing service the tool generates this message (which i suspect is what you might also have seen if you added some debug output via arcpy.AddMessage(arcpy.GetMessages())):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;Start Time: Thursday, July 27, 2023 9:46:14 AM&amp;nbsp;&lt;STRONG&gt;WARNING 002847: No labels to convert. There are no feature layers that are labeled at the conversion scale&lt;/STRONG&gt;. Succeeded at Thursday, July 27, 2023 9:46:16 AM (Elapsed Time: 2.25 seconds)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The layer in question is visible, has labelling turned on and has no scale restriction value that impedes the generation of a label at the map scale I am asking (and which works perfectly with the exact same values when run from within Pro).&amp;nbsp;&lt;/P&gt;&lt;P&gt;When ALL_LAYERS is used for 'which_layers' it does generate but this is not what I need.&lt;/P&gt;&lt;P&gt;I have spun my wheels a lot on this, trying various things and testing in Pro and Enterprise. I feel like it is somehow tied to the fact that when opening the aprx from the Enterprise service context there is no active map (even though the aprx is saved with one). Asking for the activeMap from the ProProject gives None unlike when using from CURRENT within a Pro context. Instead I have to use listMaps()[0].&lt;/P&gt;&lt;P&gt;I'm probably at the point of raising a support issue but just wanted to ask here before I do.&lt;/P&gt;&lt;P&gt;Many thanks,&lt;/P&gt;&lt;P&gt;mark&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2023 18:21:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1312727#M68268</guid>
      <dc:creator>MarkReddick</dc:creator>
      <dc:date>2023-07-27T18:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: Run standalone python script outside Arc Pro 2.9</title>
      <link>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1313715#M68301</link>
      <description>&lt;P&gt;Just back from the weekend and catching up on some reading i see that the activeView and activeMap will always be None when run from outside of the Pro application. So that is unlikely to be the cause of the issue for the case of SINGLE_LAYER never finding any labels to convert.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2023 17:31:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1313715#M68301</guid>
      <dc:creator>MarkReddick</dc:creator>
      <dc:date>2023-07-31T17:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: Run standalone python script outside Arc Pro 2.9</title>
      <link>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1339292#M68986</link>
      <description>&lt;P&gt;Did you figure this out? Mine won't run without actually opening the aprx files themselves. It doesn't like my "input_map" parameters.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 19:03:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-standalone-python-script-outside-arc-pro-2-9/m-p/1339292#M68986</guid>
      <dc:creator>ASw93</dc:creator>
      <dc:date>2023-10-18T19:03:13Z</dc:date>
    </item>
  </channel>
</rss>

