-2

I want to launch python program with a bunch of arguments from c#. I tried the solution provided in the link: How do I run a Python script from C#? , but it was not working for me. I also tried

public void LaunchProgram(string filepath, string args)
        {
            Process p = new Process();
            p.StartInfo.FileName = "python.exe";
            p.StartInfo.UseShellExecute = true; ;
            p.StartInfo.Arguments = filepath + " " + args ;
            p.Start();
        }

However, it is not working either. I would like to know what is the right way to pass a bunch of parameters in this condition? Thanks!

Update: This code is actually part of the wcf service. I got error in the line "p.start();" with the following error:

enter image description here

However, if I put this code in the console application, it works fine. I would like to know whether I need to do something in the service code?

More Update:

I can solve the above problem "The system cannot find the file specified" now by specifying the full path of python. However, if I run my client call the service, my python script is not running and the code does not show me any error either. I would like to know what would the problem this time be? Besides, I would like to know whether there is any good way to debug this kind of problem?

7
  • What are you seeing when you try to run this code? What parameters have you tried with your method? Commented Jul 28, 2015 at 20:53
  • What is the error you are getting? You may need to provide the full path to python.exe Commented Jul 28, 2015 at 20:53
  • I updated my question, thank you! Commented Jul 29, 2015 at 13:40
  • stackoverflow.com/questions/15921007/… Commented Jul 29, 2015 at 13:49
  • I set my service has the permission to access the file, but still got the same error. Commented Jul 29, 2015 at 15:31

1 Answer 1

0

I have solved the problem by give permission to everyone to access the folder where has python.exe.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.