<?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: How do I get a Python script to execute another Python script from ArcMap? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-do-i-get-a-python-script-to-execute-another/m-p/725507#M56213</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Use subprocess:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; here = os.path.abspath('.')
&amp;nbsp;&amp;nbsp;&amp;nbsp; pyfile = os.path.join(here, 'StandDiaryODBC2.py')
&amp;nbsp;&amp;nbsp;&amp;nbsp; clst = [sys.executable, pyfile]
&amp;nbsp;&amp;nbsp;&amp;nbsp; DETACHED_PROCESS = 0x00000008
&amp;nbsp;&amp;nbsp;&amp;nbsp; p = subprocess.Popen(clst, shell=False, creationflags=DETACHED_PROCESS)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You may be able to get by without the creationflags arg, but you'll just have to see.&amp;nbsp; One cool thing about subprocess.Popen is that you pass it a list of commands and args, from which it correctly builds a command line (usually!).&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 07:01:34 GMT</pubDate>
    <dc:creator>MikeHunter</dc:creator>
    <dc:date>2021-12-12T07:01:34Z</dc:date>
    <item>
      <title>How do I get a Python script to execute another Python script from ArcMap?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-get-a-python-script-to-execute-another/m-p/725506#M56212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wrote a Python 2.6 script which calls another two Python scripts to help with my workflow.&amp;nbsp; They work great when I run them from Komodo IDE, but the adapted version of the main script fails to execute the other two scripts when run from ArcGIS 10.0.&amp;nbsp; The code is as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
import os

command = 'Y:/scripts/import_landsat_RGB.py' 
os.path.normcase(os.path.normpath(command))
outargs =command+' '+j[4]+' '+outpath
fi, foe = os.popen4(outargs) 
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After viewing various posts here I tried this to no avail:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
import os

command = 'Y:/scripts/import_landsat_RGB.py' 
os.path.normcase(os.path.normpath(command))
pyexe = 'D:/Python26/ArcGIS10.0/python.exe'
os.path.normcase(os.path.normpath(pyexe))
outargs =pyexe+' '+command+' '+j[4]+' '+outpath
fi, foe = os.popen4(outargs)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyone know what I am doing wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Guy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Jun 2012 23:26:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-get-a-python-script-to-execute-another/m-p/725506#M56212</guid>
      <dc:creator>GuySerbin</dc:creator>
      <dc:date>2012-06-07T23:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get a Python script to execute another Python script from ArcMap?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-get-a-python-script-to-execute-another/m-p/725507#M56213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Use subprocess:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; here = os.path.abspath('.')
&amp;nbsp;&amp;nbsp;&amp;nbsp; pyfile = os.path.join(here, 'StandDiaryODBC2.py')
&amp;nbsp;&amp;nbsp;&amp;nbsp; clst = [sys.executable, pyfile]
&amp;nbsp;&amp;nbsp;&amp;nbsp; DETACHED_PROCESS = 0x00000008
&amp;nbsp;&amp;nbsp;&amp;nbsp; p = subprocess.Popen(clst, shell=False, creationflags=DETACHED_PROCESS)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You may be able to get by without the creationflags arg, but you'll just have to see.&amp;nbsp; One cool thing about subprocess.Popen is that you pass it a list of commands and args, from which it correctly builds a command line (usually!).&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:01:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-get-a-python-script-to-execute-another/m-p/725507#M56213</guid>
      <dc:creator>MikeHunter</dc:creator>
      <dc:date>2021-12-12T07:01:34Z</dc:date>
    </item>
  </channel>
</rss>

