<?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 Launching a python script (and a python subscript) with a batch file (troubles with os.spawnv / subprocess.Popen) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/launching-a-python-script-and-a-python-subscript/m-p/187171#M14400</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm writing a python script to load a big raster directory (552 files, 50 Go) into a mxd file in order to publish it easily with ArcGIS Server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, 300+ files is too much to had in one time, so, with the help of ERSI France, we use a subscript who add 100 files at a time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The scripts are working fine by themself, but my boss want to make easy to use by the IT outsourcing and wants to launch it through a .bat file with all the parameters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I launch the script I get a read/write error:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;with os.spawnv()&lt;/LI&gt;&lt;/UL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family: andale mono, monospace;"&gt;Traceback (most recent call last):&lt;/SPAN&gt;
&lt;SPAN style="font-family: andale mono, monospace;"&gt;&amp;nbsp; File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 168, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;
&lt;SPAN style="font-family: andale mono, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __main()&lt;/SPAN&gt;
&lt;SPAN style="font-family: andale mono, monospace;"&gt;&amp;nbsp; File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 152, in __main&lt;/SPAN&gt;
&lt;SPAN style="font-family: andale mono, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; subscript(pythonPath, pathToFile, author, title, listRaster)&lt;/SPAN&gt;
&lt;SPAN style="font-family: andale mono, monospace;"&gt;&amp;nbsp; File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 35, in subscript&lt;/SPAN&gt;
&lt;SPAN style="font-family: andale mono, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.spawnv(os.P_WAIT, pythonPath, parameterList)&lt;/SPAN&gt;
&lt;SPAN style="font-family: andale mono, monospace;"&gt;OSError: [Errno 13] Permission denied&lt;/SPAN&gt;&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;with subprocess.Popen()&lt;/LI&gt;&lt;/UL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Traceback (most recent call last):
&amp;nbsp; File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 168, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; __main()
&amp;nbsp; File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 152, in __main
&amp;nbsp;&amp;nbsp;&amp;nbsp; subscript(pythonPath, pathToFile, author, title, listRaster)
&amp;nbsp; File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 36, in subscript
&amp;nbsp;&amp;nbsp;&amp;nbsp; subprocess.Popen([pythonPath, parameterList])
&amp;nbsp; File "C:\Python27\ArcGIS10.5\lib\subprocess.py", line 390, in __init__
&amp;nbsp;&amp;nbsp;&amp;nbsp; errread, errwrite)
&amp;nbsp; File "C:\Python27\ArcGIS10.5\lib\subprocess.py", line 640, in _execute_child
&amp;nbsp;&amp;nbsp;&amp;nbsp; startupinfo)
WindowsError: [Error 5] Accès refus&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The mxd file is created by the first py script but it seems that the second one can't access it. It even seems that the second&amp;nbsp; is not even activated (don't execute a print command).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using ArcMap 10.5.1 with python 2.7.13 on a win10 computer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas how to solve this ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nicolas from France&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 16:09:43 GMT</pubDate>
    <dc:creator>NicolasRoelandt</dc:creator>
    <dc:date>2021-12-12T16:09:43Z</dc:date>
    <item>
      <title>Launching a python script (and a python subscript) with a batch file (troubles with os.spawnv / subprocess.Popen)</title>
      <link>https://community.esri.com/t5/python-questions/launching-a-python-script-and-a-python-subscript/m-p/187171#M14400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm writing a python script to load a big raster directory (552 files, 50 Go) into a mxd file in order to publish it easily with ArcGIS Server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, 300+ files is too much to had in one time, so, with the help of ERSI France, we use a subscript who add 100 files at a time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The scripts are working fine by themself, but my boss want to make easy to use by the IT outsourcing and wants to launch it through a .bat file with all the parameters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I launch the script I get a read/write error:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;with os.spawnv()&lt;/LI&gt;&lt;/UL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family: andale mono, monospace;"&gt;Traceback (most recent call last):&lt;/SPAN&gt;
&lt;SPAN style="font-family: andale mono, monospace;"&gt;&amp;nbsp; File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 168, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;
&lt;SPAN style="font-family: andale mono, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; __main()&lt;/SPAN&gt;
&lt;SPAN style="font-family: andale mono, monospace;"&gt;&amp;nbsp; File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 152, in __main&lt;/SPAN&gt;
&lt;SPAN style="font-family: andale mono, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; subscript(pythonPath, pathToFile, author, title, listRaster)&lt;/SPAN&gt;
&lt;SPAN style="font-family: andale mono, monospace;"&gt;&amp;nbsp; File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 35, in subscript&lt;/SPAN&gt;
&lt;SPAN style="font-family: andale mono, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.spawnv(os.P_WAIT, pythonPath, parameterList)&lt;/SPAN&gt;
&lt;SPAN style="font-family: andale mono, monospace;"&gt;OSError: [Errno 13] Permission denied&lt;/SPAN&gt;&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;with subprocess.Popen()&lt;/LI&gt;&lt;/UL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Traceback (most recent call last):
&amp;nbsp; File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 168, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; __main()
&amp;nbsp; File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 152, in __main
&amp;nbsp;&amp;nbsp;&amp;nbsp; subscript(pythonPath, pathToFile, author, title, listRaster)
&amp;nbsp; File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 36, in subscript
&amp;nbsp;&amp;nbsp;&amp;nbsp; subprocess.Popen([pythonPath, parameterList])
&amp;nbsp; File "C:\Python27\ArcGIS10.5\lib\subprocess.py", line 390, in __init__
&amp;nbsp;&amp;nbsp;&amp;nbsp; errread, errwrite)
&amp;nbsp; File "C:\Python27\ArcGIS10.5\lib\subprocess.py", line 640, in _execute_child
&amp;nbsp;&amp;nbsp;&amp;nbsp; startupinfo)
WindowsError: [Error 5] Accès refus&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The mxd file is created by the first py script but it seems that the second one can't access it. It even seems that the second&amp;nbsp; is not even activated (don't execute a print command).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using ArcMap 10.5.1 with python 2.7.13 on a win10 computer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas how to solve this ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nicolas from France&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:09:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/launching-a-python-script-and-a-python-subscript/m-p/187171#M14400</guid>
      <dc:creator>NicolasRoelandt</dc:creator>
      <dc:date>2021-12-12T16:09:43Z</dc:date>
    </item>
  </channel>
</rss>

