<div>Whether it's CPython or IronPython, you're going to have to deploy something to the user's PC if you want to run a Python program there. IronPython doesn't have any kind of installer; you just copy its modules over with your application. But your program almost certainly makes use of parts of the standard CPython library, which you'd then have to copy over as well.</div>
<div> </div>
<div>Even though CPython has an installer under Windows, I suspect you can still do an "xcopy deployment" of it to most machines provided that you also grab a copy of Python25.dll from the Windows directory.<br>
</div>
<div>To try with IronPython,</div>
<div>You can run ipy.exe the same way as you're running python.exe. But you'd want to try this from a command prompt first before going to the trouble of changing your C# program.<br></div>
<div class="gmail_quote">On Wed, Jun 11, 2008 at 3:40 PM, Bob Rosembob <<a href="mailto:brosembob@yahoo.com">brosembob@yahoo.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">Thank you Michael and Curt for your quick response. </div>
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">I got the script working using the following logic:</div>
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><font color="#0000ff" size="2"><font color="#0000ff" size="2">
<p> </p>
<p>private</p></font></font><font size="2"></font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Process</font></font><font size="2"> P;</font>
<p><font size="2">...</font></p></div>
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"><font size="2"></font><font color="#0000ff" size="2"><font color="#0000ff" size="2"><font size="2">
<p></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">string</font></font><font size="2"> python = </font><font color="#a31515" size="2"><font color="#a31515" size="2">@"C:\Python25\python.exe"</font></font><font size="2">;
<p></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">string</font></font><font size="2"> pyscript = </font><font color="#a31515" size="2"><font color="#a31515" size="2">@"IronPython\cycle_LR.py"</font></font><font size="2">;
<p>P = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">new</font></font><font size="2"> </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Process</font></font><font size="2">();
<p>P.OutputDataReceived += </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">new</font></font><font size="2"> </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">DataReceivedEventHandler</font></font><font size="2">(OnOutputDataReceived);
<p>P.ErrorDataReceived += </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">new</font></font><font size="2"> </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">DataReceivedEventHandler</font></font><font size="2">(OnErrorReceived);
<p>P.StartInfo.UseShellExecute = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">false</font></font><font size="2">;
<p>P.StartInfo.RedirectStandardOutput = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">true</font></font><font size="2">;
<p>P.StartInfo.RedirectStandardError = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">true</font></font><font size="2">;
<p>P.StartInfo.CreateNoWindow = </p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">true</font></font><font size="2">;
<p>P.StartInfo.FileName = @python.ToString();</p>
<p>P.StartInfo.Arguments = </p></font><font color="#a31515" size="2"><font color="#a31515" size="2">"-u "</font></font><font size="2"> + pyscript.ToString() + </font><font color="#a31515" size="2"><font color="#a31515" size="2">@" IronPython\cycle.ini"</font></font><font size="2">;
<p>P.Start();</p>
<p>P.BeginOutputReadLine();</p>
<p>P.BeginErrorReadLine();</p></font></font></font></div>
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif"> </div>
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<p>As you probably guessed I installed latest Python 2.5.2 on my machine. </p>
<p>Now, do I need to include Python 2.5.2 into my deployment package and install it on the user's PC or I can some how embed it into my application?</p>
<div class="Ih2E3d">
<p> </p>
<p><font color="#434343">>>If the former then you can use System.Process to launch the script with <br>>>IronPython. You will need to download (rather than install) and launch <br>>>the script with 'ipy.exe args...'.</font></p>
<p> </p></div>
<p>Wouldn't this approach be simpler, since I don't have to install python on user's PC? How exactly can I run ipy.exe with the args?<br></p>
<p>Curt, </p>
<p>The script that I have to use was created in 2004 and probably was not tested with IronPython. The guy who created it left the company and nobody modified the script since.</p>
<p><br>Thank you very much,</p>
<p>Bob</p>
<p> </p>
<p> </p></div>
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<div class="Ih2E3d">----- Original Message ----<br>From: Michael Foord <<a href="mailto:fuzzyman@voidspace.org.uk" target="_blank">fuzzyman@voidspace.org.uk</a>><br>To: Discussion of IronPython <<a href="mailto:users@lists.ironpython.com" target="_blank">users@lists.ironpython.com</a>><br>
Sent: Wednesday, June 11, 2008 1:29:27 PM<br>Subject: Re: [IronPython] Talk to Python script from C# app...<br><br>Hello Bob,<br><br>The question is, do you want to run it in the same way you would launch <br>any command line application from C# and collect the results from <br>
standard out - or do you want to embed IronPython and run the script <br>'inside' your application?<br><br>If the former then you can use System.Process to launch the script with <br>IronPython. You will need to download (rather than install) and launch <br>
the script with 'ipy.exe args...'.<br><br>If the latter then how you do it depends on whether you use IronPython 1 <br>or 2 and what exactly your use case is.<br><br>Michael Foord<br><a href="http://www.ironpythoninaction.com/" target="_blank">http://www.ironpythoninaction.com/</a><br>
<br></div>
<div class="Ih2E3d">Bob Rosembob wrote:<br>> Hello there,<br>> I have a C# application and a 3rd party Python script that the <br>> application should run. The script is called periodical with some <br>> arguments, performs some calculations and returns the results. I'm <br>
> running Vista & VS2005.<br>> <br>> What should I do to run the script from my application? I assume I <br>> need to install IronPython on my PC. How exactly should I do it?<br>> <br>> Thanks for your help.<br>
> <br>> Bob<br>><br>> ------------------------------------------------------------------------<br>><br>> _______________________________________________<br>> Users mailing list<br>> <a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
> <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>> <br><br>_______________________________________________<br>
Users mailing list<br><a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br><a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
</div></div></div><br></div><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br><a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br></blockquote></div><br>