<?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: Why will python script work standalone but not in Model Builder? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/why-will-python-script-work-standalone-but-not-in/m-p/701790#M54381</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;max(list of files...&amp;nbsp; is empty&lt;/P&gt;&lt;P&gt;os.path.getctime is the key file (most recently added?)&lt;/P&gt;&lt;P&gt;So I am guessing that this path&amp;nbsp;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #669900; font-family: monospace; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px #fff; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;'//gis/Geomaster/*.bak&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;can't be found when run through the model, but can be found in the python environment because you set it?&lt;/P&gt;&lt;P&gt;Try the full path&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Oct 2018 02:39:18 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2018-10-10T02:39:18Z</dc:date>
    <item>
      <title>Why will python script work standalone but not in Model Builder?</title>
      <link>https://community.esri.com/t5/python-questions/why-will-python-script-work-standalone-but-not-in/m-p/701789#M54380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've got a pretty simple script that looks for the latest/newest file in a folder and copies it into a new location. The script works fine when run through a python GUI, but when run as a part of an Arc model, fails. Can someone translate the error for me? I don't understand why this is happening?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; glob
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; shutil
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; time

date &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; time&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;strftime&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"%Y-%m-%d"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
dst &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"//10.253.2.161/cddp/Bunbury Use Only/GeoMasterPatchArchives/"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; date

list_of_files &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; glob&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;glob&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'//gis/Geomaster/*.bak'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# * means all if need specific format then *.csv&lt;/SPAN&gt;
latest_file &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; max&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;list_of_files&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; key&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getctime&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
shutil&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;copy&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;latest_file&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; dst&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; latest_file &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;" copied to backup folder"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Results of running the script as part of an Arc model" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/424061_2018-10-10_10-23-34.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:31:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-will-python-script-work-standalone-but-not-in/m-p/701789#M54380</guid>
      <dc:creator>LindsayRaabe_FPCWA</dc:creator>
      <dc:date>2021-12-12T05:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Why will python script work standalone but not in Model Builder?</title>
      <link>https://community.esri.com/t5/python-questions/why-will-python-script-work-standalone-but-not-in/m-p/701790#M54381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;max(list of files...&amp;nbsp; is empty&lt;/P&gt;&lt;P&gt;os.path.getctime is the key file (most recently added?)&lt;/P&gt;&lt;P&gt;So I am guessing that this path&amp;nbsp;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #669900; font-family: monospace; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px #fff; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;'//gis/Geomaster/*.bak&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;can't be found when run through the model, but can be found in the python environment because you set it?&lt;/P&gt;&lt;P&gt;Try the full path&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2018 02:39:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-will-python-script-work-standalone-but-not-in/m-p/701790#M54381</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-10-10T02:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why will python script work standalone but not in Model Builder?</title>
      <link>https://community.esri.com/t5/python-questions/why-will-python-script-work-standalone-but-not-in/m-p/701791#M54382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think it must have been the pathway. It was meant to be a&amp;nbsp;complete path but I think the "gis" part was an alternative to the actual path of "bun-gis-01". I tweaked it and it worked so hopefully it keeps working. Thanks!&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Oct 2018 07:38:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-will-python-script-work-standalone-but-not-in/m-p/701791#M54382</guid>
      <dc:creator>LindsayRaabe_FPCWA</dc:creator>
      <dc:date>2018-10-10T07:38:34Z</dc:date>
    </item>
  </channel>
</rss>

