<?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: Model runs in ModelBuilder but gives error when run from Python Script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/model-runs-in-modelbuilder-but-gives-error-when/m-p/408454#M32180</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Paul - The python script (as script tool) is intended to run in the ArcMap session since it references some standard feature layers (rather than explicit feature classes) and uses in-memory layers.&amp;nbsp; Attached is the actual error Im getting.&amp;nbsp; Oddly enough, is I have an earlier version that I backed up that works with the older data.&amp;nbsp; Maybe something got corrupt in my toolbox, but just very odd and seemingly random&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" height="430" src="https://community.esri.com/legacyfs/online/442121_pastedImage_1.png" width="494" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Apr 2019 23:21:33 GMT</pubDate>
    <dc:creator>NealBanerjee</dc:creator>
    <dc:date>2019-04-15T23:21:33Z</dc:date>
    <item>
      <title>Model runs in ModelBuilder but gives error when run from Python Script</title>
      <link>https://community.esri.com/t5/python-questions/model-runs-in-modelbuilder-but-gives-error-when/m-p/408451#M32177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;I have created a toolbox and developed a series of about 20 tools in ModelBuilder that represent different components of an analysis.&amp;nbsp; Each model runs fine without error when run in model building or executed in the Python command line within ArcMap.&amp;nbsp; Some of the models are fairly complex and involve iterators, in-line variables, etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I created a script tool with an associated Python script that basically runs all the component models in sequence.&amp;nbsp; Most of the models run fine, but a few that have iterators keep giving error when run through the Python Script tool.&amp;nbsp; The first model that the script chokes on involves an iterator with the 'Get Field Value' tool that then writes a value to a variable field name based on the get value value.&amp;nbsp; The values that&amp;nbsp; should be produced start at 2 and go to 500.&amp;nbsp; However, when I run Python script it for some reason returns a value of 1 and then bombs.&amp;nbsp; Again model run fine in model builder.&amp;nbsp;&amp;nbsp; Below is an annotated screenshot of model.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Im stumped where/why it is return a value of 1.&amp;nbsp; Any ideas on why something in ModelBuilder works but not the identical process run from python script?&amp;nbsp; The input parameters and model reference work fine - so it is definitely something occurring within the model.&amp;nbsp; I cant imagine it is something in the script itself because it is just calling the model and the other models run fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Neal&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/442099_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2019 22:17:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-runs-in-modelbuilder-but-gives-error-when/m-p/408451#M32177</guid>
      <dc:creator>NealBanerjee</dc:creator>
      <dc:date>2019-04-15T22:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: Model runs in ModelBuilder but gives error when run from Python Script</title>
      <link>https://community.esri.com/t5/python-questions/model-runs-in-modelbuilder-but-gives-error-when/m-p/408452#M32178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How do the python script lines run in a python window in ArcDesktop or Pro? I wonder if you might need to implicitly call the python library with import arcpy to run in python outside of an ESRI environment. &amp;nbsp;Did your python IDE throw any error messages?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2019 22:31:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-runs-in-modelbuilder-but-gives-error-when/m-p/408452#M32178</guid>
      <dc:creator>PaulHuffman</dc:creator>
      <dc:date>2019-04-15T22:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Model runs in ModelBuilder but gives error when run from Python Script</title>
      <link>https://community.esri.com/t5/python-questions/model-runs-in-modelbuilder-but-gives-error-when/m-p/408453#M32179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I thought I recently had a problem like this. I found it. &amp;nbsp;I found out that outside ArcDesktop I had to also explicitly check out extensions.&amp;nbsp;&lt;A href="https://community.esri.com/thread/219120-why-doesnt-sa-slope-get-called-as-expected-in-python-script"&gt;https://community.esri.com/thread/219120-why-doesnt-sa-slope-get-called-as-expected-in-python-script&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2019 22:39:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-runs-in-modelbuilder-but-gives-error-when/m-p/408453#M32179</guid>
      <dc:creator>PaulHuffman</dc:creator>
      <dc:date>2019-04-15T22:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: Model runs in ModelBuilder but gives error when run from Python Script</title>
      <link>https://community.esri.com/t5/python-questions/model-runs-in-modelbuilder-but-gives-error-when/m-p/408454#M32180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Paul - The python script (as script tool) is intended to run in the ArcMap session since it references some standard feature layers (rather than explicit feature classes) and uses in-memory layers.&amp;nbsp; Attached is the actual error Im getting.&amp;nbsp; Oddly enough, is I have an earlier version that I backed up that works with the older data.&amp;nbsp; Maybe something got corrupt in my toolbox, but just very odd and seemingly random&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" height="430" src="https://community.esri.com/legacyfs/online/442121_pastedImage_1.png" width="494" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Apr 2019 23:21:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-runs-in-modelbuilder-but-gives-error-when/m-p/408454#M32180</guid>
      <dc:creator>NealBanerjee</dc:creator>
      <dc:date>2019-04-15T23:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Model runs in ModelBuilder but gives error when run from Python Script</title>
      <link>https://community.esri.com/t5/python-questions/model-runs-in-modelbuilder-but-gives-error-when/m-p/408455#M32181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you validate the model before running it from Python?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2019 02:15:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-runs-in-modelbuilder-but-gives-error-when/m-p/408455#M32181</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2019-04-16T02:15:45Z</dc:date>
    </item>
  </channel>
</rss>

