<?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: Differences between Notebook execution and Toolbox execution in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159436#M64222</link>
    <description>&lt;P&gt;When you say run as a "standalone script", how exactly are you doing that? Are you wiring it up to&amp;nbsp; &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/a-quick-tour-of-creating-script-tools.htm" target="_self"&gt;Tool script&lt;/A&gt; interface? If so I don't see you setting any parameters which would be expected as that is what a script tool is. Or are you running it in an IDE or python console outside ArcPro?&lt;/P&gt;</description>
    <pubDate>Wed, 30 Mar 2022 15:25:57 GMT</pubDate>
    <dc:creator>DuncanHornby</dc:creator>
    <dc:date>2022-03-30T15:25:57Z</dc:date>
    <item>
      <title>Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1158885#M64199</link>
      <description>&lt;P&gt;Greetings..I'm running a Python script in the Notebook environment and it works as expected.&amp;nbsp; If I try to run as a standalone script in a Toolbox, it fails unexpectedly.&amp;nbsp; Is there a difference, and what are the differences, between the Notebook runtime and the Script/Toolbox runtime?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 15:24:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1158885#M64199</guid>
      <dc:creator>Scott_T_Anderson</dc:creator>
      <dc:date>2022-03-29T15:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1158908#M64200</link>
      <description>&lt;P&gt;What's the error message?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 15:48:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1158908#M64200</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2022-03-29T15:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1158928#M64202</link>
      <description>&lt;P&gt;Hey Duncan, thanks for the reply.&amp;nbsp; I don't get an error message, just inconsistent behaviour.&amp;nbsp; For instance, if I use the JoinField function in the Notebook environment between a feature and a table, it behaves as expected.&amp;nbsp; If I run the same script as a Toolbox script, it does not error, completes as expected but fails to make, or maybe save, the join. Is there some automatic functionality in the Notebook environment that saves that join result for me that doesn't exist in the Toolbox environment?&lt;/P&gt;&lt;P&gt;I should add, this is early days for me in Python, so speak to me like I'm a Labrador Retriever...&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 16:11:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1158928#M64202</guid>
      <dc:creator>Scott_T_Anderson</dc:creator>
      <dc:date>2022-03-29T16:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1158963#M64203</link>
      <description>&lt;P&gt;Another thought..are the Environment settings different in the Notebook runtime vs the Script runtime?&amp;nbsp; Things like, AutoCommit, Maintain Fully Qualified Field Names. Do I need to explicitly set these values or are they inherited from the APRX environment at runtime for both the Notebook and Tool Script environments?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 17:12:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1158963#M64203</guid>
      <dc:creator>Scott_T_Anderson</dc:creator>
      <dc:date>2022-03-29T17:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159004#M64204</link>
      <description>&lt;P&gt;Further information.&amp;nbsp; I'm actually creating a table using the TableToTable Conversion function.&amp;nbsp; The table gets created, is added to my local geodb, is added to my map and then joined to an existing feature. If i perform these tasks in the Notebook environment, the join is added successfully.&amp;nbsp; If it do this in the Toolbox environment, it does not create/save the join.&amp;nbsp; If the table already exists (ie I don't create it in my script..) then it will create and save the join correctly.&amp;nbsp; So it would appear that something in the TableToTable conversion function is not the same in Notebook vs Toolbox.&amp;nbsp; Is there some necessity to "save" the table in a special fashion to make it available to the subsequent calls in the Toolbox environment?&amp;nbsp; It's successfully added to my geodb and map in the Toolbox environment but it fails to execute the join correctly. Fairly annoying...&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 18:21:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159004#M64204</guid>
      <dc:creator>Scott_T_Anderson</dc:creator>
      <dc:date>2022-03-29T18:21:09Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159080#M64209</link>
      <description>&lt;P&gt;So this is the same issue I believe.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-questions/arcgis-pro-python-addjoin/td-p/1016171/page/2" target="_blank"&gt;https://community.esri.com/t5/python-questions/arcgis-pro-python-addjoin/td-p/1016171/page/2&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 20:05:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159080#M64209</guid>
      <dc:creator>Scott_T_Anderson</dc:creator>
      <dc:date>2022-03-29T20:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159275#M64215</link>
      <description>&lt;P&gt;Scott,&lt;/P&gt;&lt;P&gt;Without seeing your code it's difficult to offer up a solution. I have to confess I don't use the notebook environment, and see little use for it.&lt;/P&gt;&lt;P&gt;I would normally develop a script in an IDE such as spyder and either run it there directly or paste it into the python console or wire it up to a script tool interface, which sounds like what you are doing.&lt;/P&gt;&lt;P&gt;I would be surprised if notebook implements environmental settings in a different way to toolbox so my suspicion is that its a flaw in the code and if you shared it with some of your data and I too replicate the problem then that would be good evidence to log a bug with esri.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 09:15:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159275#M64215</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2022-03-30T09:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159401#M64220</link>
      <description>&lt;P&gt;Thanks Duncan.&amp;nbsp; I messed around last night doing some stuff and realized that my issue is likely the referencing of items in my current ArcPro session in the Notebook environment vs trying to access these items from a standalone script.&amp;nbsp; I think this is a fundamental thing I have to understand better.&amp;nbsp; For instance, in a standalone script, can i get a handle on the aprx, then a map, then add a layer in the map from a standalone script?&amp;nbsp; Within the Notebook environment it's implicit where these things are going.&amp;nbsp; From standalone, I'm not sure I'm accessing the map etc correctly to be able to add and modify layers.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 14:20:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159401#M64220</guid>
      <dc:creator>Scott_T_Anderson</dc:creator>
      <dc:date>2022-03-30T14:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159411#M64221</link>
      <description>&lt;P&gt;Here is a little snippet.&amp;nbsp; This fails to add the table when run as standalone. I'm not sure that I am addressing the aprx correctly and it's not able to add or save the table addition.&amp;nbsp; Any insight would be great.&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;# set geodb to be worked on&lt;BR /&gt;arcpy.env.workspace = r"C:\LocalWork\SLN_Replacement\SLN_Replacement.gdb"&lt;BR /&gt;#aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;BR /&gt;aprx = arcpy.mp.ArcGISProject(r"C:\LocalWork\SLN_Replacement\SLN_Replacement.aprx")&lt;BR /&gt;m = aprx.listMaps("Map")[0]&lt;/P&gt;&lt;P&gt;# get handle on table to add&lt;BR /&gt;addTab = arcpy.mp.Table(r"C:\LocalWork\SLN_Replacement\SLN_Replacement.gdb\AddressWorking")&lt;BR /&gt;# set flag&lt;BR /&gt;found = 0&lt;/P&gt;&lt;P&gt;# test for AddressWorking already in the Map and add if needed&lt;BR /&gt;tables = m.listTables()&lt;BR /&gt;print("Got tables list.")&lt;BR /&gt;if tables is not None:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for table in m.listTables():&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if table.name == "AddressWorking":&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print("Found AddressWorking.")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.AddMessage("Found AddressWorking.")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; found = 1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if found == 0:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print("Adding AddressWorking.")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; m.addTable(addTab)&lt;/P&gt;&lt;P&gt;# save aprx&lt;BR /&gt;aprx.save&lt;/P&gt;&lt;P&gt;# clean up&lt;BR /&gt;del aprx, m, tables, found&lt;/P&gt;&lt;P&gt;print("Done.")&lt;BR /&gt;arcpy.AddMessage("Done.")&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 14:39:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159411#M64221</guid>
      <dc:creator>Scott_T_Anderson</dc:creator>
      <dc:date>2022-03-30T14:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159436#M64222</link>
      <description>&lt;P&gt;When you say run as a "standalone script", how exactly are you doing that? Are you wiring it up to&amp;nbsp; &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/a-quick-tour-of-creating-script-tools.htm" target="_self"&gt;Tool script&lt;/A&gt; interface? If so I don't see you setting any parameters which would be expected as that is what a script tool is. Or are you running it in an IDE or python console outside ArcPro?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 15:25:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159436#M64222</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2022-03-30T15:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159437#M64223</link>
      <description>&lt;P&gt;So I'm basically dev'ing it in the Notebook and then saving to a .py file and running as a Tool Script.&amp;nbsp; What parameters would be required?&amp;nbsp; Typically.&amp;nbsp; Is this well documented in the Python docs? I can look it up if so.&amp;nbsp; Again, thanks for your tolerance Duncan.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 15:31:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159437#M64223</guid>
      <dc:creator>Scott_T_Anderson</dc:creator>
      <dc:date>2022-03-30T15:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159460#M64224</link>
      <description>&lt;P&gt;I think the issue is with the save() method on the project. Here is my minimal code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('Map')[0]
addTab = arcpy.mp.Table(r"C:\Scratch\fGDB_Scratch.gdb\London")
m.addTable(addTab)
# p.save() # This does not work!
p.saveACopy(r"C:\temp\Scott\Scott2.aprx")
arcpy.AddMessage("Saved!")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I connected the script to a tool script but as there are no input parameters the tool runs as this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="DuncanHornby_0-1648655555326.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37716i317773DD2FFA7F4B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DuncanHornby_0-1648655555326.png" alt="DuncanHornby_0-1648655555326.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Table is added as shown below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="DuncanHornby_1-1648655616031.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37717iA09768E5DACBBC9B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DuncanHornby_1-1648655616031.png" alt="DuncanHornby_1-1648655616031.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now if I use p.save() instead of p.saveACopy() then the table&amp;nbsp;&lt;STRONG&gt;IS NOT&lt;/STRONG&gt; saved to the project. This seems like a bug to me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 15:56:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159460#M64224</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2022-03-30T15:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159506#M64225</link>
      <description>&lt;P&gt;I suppose if you're in the same aprx file that you're trying to save from a Tool script, the file may be locked and unable to be saved.&amp;nbsp; Perhaps I'll try from another aprx and see if this the case.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 16:51:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159506#M64225</guid>
      <dc:creator>Scott_T_Anderson</dc:creator>
      <dc:date>2022-03-30T16:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159510#M64226</link>
      <description>&lt;P&gt;I guess another question is, is there an elegant way to run a script inside your current session other than a Tool Script or hitting the Run button inside the Notebook environment?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 16:54:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159510#M64226</guid>
      <dc:creator>Scott_T_Anderson</dc:creator>
      <dc:date>2022-03-30T16:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159788#M64238</link>
      <description>&lt;P&gt;Looks like a bug introduced by ESRI in the latest version.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-questions/project-service-aprx-object-save-error-from-pro-2/m-p/1119713#M63045" target="_blank"&gt;https://community.esri.com/t5/python-questions/project-service-aprx-object-save-error-from-pro-2/m-p/1119713#M63045&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 08:58:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1159788#M64238</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2022-03-31T08:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Differences between Notebook execution and Toolbox execution</title>
      <link>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1162206#M64304</link>
      <description>&lt;P&gt;So I've learned a few things..but not everything..about this particular situation. The functions that were failing I believe are mostly because I was trying to manipulate the aprx I was currently in using a Tool Script, which functions outside of the current environment.&amp;nbsp; I don't think changes are saved automatically and I don't think they CAN be saved because I'm in the aprx in my own session outside of the Python session.&lt;/P&gt;&lt;P&gt;I've resigned myself to running my scripts via the Notebook interface and using CURRENT as my aprx parameter.&amp;nbsp; This behaves as expected but is a bit ugly because you're running the script from the Notebook dev environment's Run button.&lt;/P&gt;&lt;P&gt;If anyone else stumbles into this, the difference between how a Notebook script using the CURRENT parameter vs a standalone script trying to access the current aprx file is significant.&amp;nbsp; I will try to automate the script by using a button instead of a Tool script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you Duncan for endeavouring to locate my issues.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 16:54:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/differences-between-notebook-execution-and-toolbox/m-p/1162206#M64304</guid>
      <dc:creator>Scott_T_Anderson</dc:creator>
      <dc:date>2022-04-07T16:54:11Z</dc:date>
    </item>
  </channel>
</rss>

