Home > Net > C # to call python suddenly appear problem, StandardOutput
C # to call python suddenly appear problem, StandardOutput
Time:09-21
C # call python suddenly appear problem, I do GNSS before using CMD call python, ready to change the program today, my hand is out of control with boring tinder, clean up the file with the registry, and then not move before success code, run a python output is null, I again make the python environment remains no fixed (py test files can be started from the vs and CMD command to start the output), Part of the code Public static void RunPythonScript (string sArgName, string args="", params string [] teps) { The Process of p=new Process (); //string path=System. The AppDomain. CurrentDomain. SetupInformation. ApplicationBase + sArgName;//get the python file's absolute path (put file in c # the debug folder can operation) String path=@ "D: \ ana \ Lib" + sArgName;//(because I didn't put the debug, so write directly absolute path, replace the path above) P. tartInfo. FileName=@ "D: \ ana \ python exe";//(note: the words into your own) doesn't match the environment variable, you can like me to write python. Exe the absolute path (words into your own), if match, write directly "python. Exe can "String sArguments=path; The foreach (string sigstr in teps) { SArguments +="" + sigstr;//pass parameters }
for (int i=0; I & lt; StrArr. Length; I++) { IntArr [I]=the Convert. ToDouble (strArr [I]); } A=b; ;
}
} E.d ate value is null, I tried to reinstall the application and no role in doubt CMD failed to lift the python, or StandardOutput gave an issue,
CodePudding user response:
A debug method is by calling the CMD command line, and removing RedirectStandardOutput etc. The value of the attribute, a default value is set false
Then performed by the CMD command to start the Py then let Py command, you can see the Py have to output, and the content of the output, according to the contents of the output can be the next step debugging
How the CMD incoming parameters see [CMD. Exe command-line launch parameters (can be used to execute the command, the cords or environment configuration) - walterlv] (https://walterlv.com/post/cmd-startup-arguments.html)
[how to start CMD software to take the path of the space] (https://blog.lindexi.com/post/%E5%A6%82%E4%BD%95%E5%9C%A8-CMD-%E5%90%AF%E5%8A%A8%E7%9A%84%E8%BD%AF%E4%BB%B6%E4%BC%A0%E5%85%A5%E5%B8%A6%E7%A9%BA%E6%A0%BC%E7%9A%84%E8%B7%AF%E5%BE%84.html)