0

Am trying to run python script file using ASP.NET C#. Using Python.net since IronPython does not support libraries I use. Is there any Python.net resources or example projects that I may possible use?

I want to pass the id from C# to the end() and get the similar_ids back to C#. Am facing serious difficulty coding the C# part.

Not sure if the C# code is correct implementation bc this is my first python project. C# code

private string run_cmd()
        {

            string fileName = @"C:/Users/hongy/OneDrive/Desktop/fypV2/v1.py";
            string python = @"C:/Users/hongy/AppData/Local/Programs/Python/Python311/python.exe";

            Process psi = new Process();
            psi.StartInfo = new ProcessStartInfo(python, fileName)
            {
                RedirectStandardOutput = true,
                UseShellExecute = false,
                CreateNoWindow = true
            };
            psi.Start();

            string output = psi.StandardOutput.ReadToEnd();

            return output;
        }

Python code

def end(id):
    similar_ids = find_similar_jobs(id, X, k=5)
    for i in similar_ids:
        print(p[i])
Dababy
  • 3
  • 3
  • You could deliver the id as a parameter to the Python script. Just append then id to Your filename-parameter and grab it inside the Python script. – Claus H Mar 02 '23 at 09:25

0 Answers0