I want to pass a parameter from a C# code to Python using ProcessStartInfo. I am obliged to avoid IronPython (by creating a scope) because of its incompatibility with numpy. I found some answers which are unsuccessful. Here is what I wrote:
var x = 8;
string arg = string.Format(@"C:\Users\ayed\Desktop\IronPythonExamples\RunExternalScript\plot.py", x);
try
{
Process p = new Process();
p.StartInfo = new ProcessStartInfo(@"D:\WinPython\WinPython-64bit-2.7.5.3\python-2.7.5.amd64\python.exe", arg);
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
p.WaitForExit();
}
catch (Exception ex)
{
Console.WriteLine("There is a problem in your Python code: " + ex.Message);
}
Console.WriteLine("Press enter to exit...");
Console.ReadLine();
The test python code allows to plot a curve and print the value of x. Ok for the curve, but I am getting this exception: name 'x' is not defined.
How can I properly pass a variable to this python code?