<?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 Executing Python programs with Run Program() in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Executing-Python-programs-with-Run-Program/m-p/337888#M58551</link>
    <description>&lt;P&gt;I am having an issue that should be related to the nested calls I am doing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RunProgram() --&amp;gt; cmd --&amp;gt; Python&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following bat file works perfectly fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;set JMP_PYTHON_PTH=%UserProfile%\miniconda_JMP\

CALL %JMP_PYTHON_PTH%\Scripts\activate.bat %JMP_PYTHON_PTH%

start /B /wait "" python test.py&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And yet, when using RunProgram() the code fails unless I add the absolute path to the Python file (test.py --&amp;gt; 'C:/a/b/c/test.py')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ClearLog();

file_path = ConvertFilePath( "./tests/run_python_installation_test.bat", windows);

rp = RunProgram( Executable( "cmd.exe" ),
	Options( {"/C", file_path} ),
	ReadFunction("text") // returns all text	
	);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The error I get, again only if the absolute path is not given, is the following.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;(base) C:\WINDOWS\system32&amp;gt;start /B /wait \!"\!" python test.py 
python: can't open file 'test.py': [Errno 2] No such file or directory&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 21:59:19 GMT</pubDate>
    <dc:creator>FN</dc:creator>
    <dc:date>2023-06-09T21:59:19Z</dc:date>
    <item>
      <title>Executing Python programs with Run Program()</title>
      <link>https://community.jmp.com/t5/Discussions/Executing-Python-programs-with-Run-Program/m-p/337888#M58551</link>
      <description>&lt;P&gt;I am having an issue that should be related to the nested calls I am doing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RunProgram() --&amp;gt; cmd --&amp;gt; Python&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following bat file works perfectly fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;set JMP_PYTHON_PTH=%UserProfile%\miniconda_JMP\

CALL %JMP_PYTHON_PTH%\Scripts\activate.bat %JMP_PYTHON_PTH%

start /B /wait "" python test.py&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And yet, when using RunProgram() the code fails unless I add the absolute path to the Python file (test.py --&amp;gt; 'C:/a/b/c/test.py')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ClearLog();

file_path = ConvertFilePath( "./tests/run_python_installation_test.bat", windows);

rp = RunProgram( Executable( "cmd.exe" ),
	Options( {"/C", file_path} ),
	ReadFunction("text") // returns all text	
	);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The error I get, again only if the absolute path is not given, is the following.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;(base) C:\WINDOWS\system32&amp;gt;start /B /wait \!"\!" python test.py 
python: can't open file 'test.py': [Errno 2] No such file or directory&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 21:59:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Executing-Python-programs-with-Run-Program/m-p/337888#M58551</guid>
      <dc:creator>FN</dc:creator>
      <dc:date>2023-06-09T21:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: Executing Python programs with Run Program()</title>
      <link>https://community.jmp.com/t5/Discussions/Executing-Python-programs-with-Run-Program/m-p/337927#M58554</link>
      <description>&lt;P&gt;When I run this&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;file_path = convertfilepath("$temp/x.bat","windows");
savetextfile(file_path, "dir\!n");

rp = RunProgram( Executable( "cmd.exe" ),
	Options( {"/C", file_path} ),
	ReadFunction("text") // returns all text	
	);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;it appears the working directory for the bat file execution is my desktop directory. I think python will use the working directory to find the filename on the command line too. Using the full path name seems a good choice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://superuser.com/questions/396394/how-do-i-set-an-executables-working-directory-via-the-command-line-prior-to-ex" target="_blank" rel="noopener"&gt;https://superuser.com/questions/396394/how-do-i-set-an-executables-working-directory-via-the-command-line-prior-to-ex&lt;/A&gt;&amp;nbsp; suggests you can specify the working directory in your start command:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;START /D c:\temp notepad.exe&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Nov 2020 21:26:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Executing-Python-programs-with-Run-Program/m-p/337927#M58554</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2020-11-27T21:26:11Z</dc:date>
    </item>
  </channel>
</rss>

