Answers for "call python script from c#"

C#
3

run python script from c#

using IronPython.Hosting;
using Microsoft.Scripting.Hosting;

private static void doPython()
{
    ScriptEngine engine = Python.CreateEngine();
    engine.ExecuteFile(@"test.py");
}

//You can get IronPython here : https://ironpython.net/
Posted by: Guest on July-09-2021
1

call python script from c#

private void run_cmd(string cmd, string args)
{
     ProcessStartInfo start = new ProcessStartInfo();
     start.FileName = "my/full/path/to/python.exe";
     start.Arguments = string.Format("{0} {1}", cmd, args);
     start.UseShellExecute = false;
     start.RedirectStandardOutput = true;
     using(Process process = Process.Start(start))
     {
         using(StreamReader reader = process.StandardOutput)
         {
             string result = reader.ReadToEnd();
             Console.Write(result);
         }
     }
}
Posted by: Guest on September-01-2021
-1

run python from c#

string strCmdText;
string file;
file = "py.py"
strCmdText= "python3" + file;
System.Diagnostics.Process.Start("CMD.exe",strCmdText);
Posted by: Guest on July-21-2021

Code answers related to "call python script from c#"

C# Answers by Framework

Browse Popular Code Answers by Language