locked
Python Script is not getting executed from C# RRS feed

  • Question

  • Hi Team,

    I was trying to execute python script from C#.net but it fails to execute. In the below code, entire python script is holding it to src string variable and passing to py.CreateScriptSourceFromString() method and executing source by passing scope object. when it executes the script it generates an text file. The below code is executing fine without errors but text file generates without data. if we executes the same script manually it fills data in text file. Can you please suggest how can i accommodate the code here?

                                    Directory.SetCurrentDirectory(path + FCDVersion + @"\");
                                    string src = File.ReadAllText(outputpath);
                                    var py = Python.CreateEngine();
                                    var paths=py.GetSearchPaths();
                                    paths.Add(@"C:\Program Files (x86)\IronPython 2.7\Lib");
                                    py.SetSearchPaths(paths);
                                    ScriptSource source=py.CreateScriptSourceFromString(src);
                                    ScriptScope scope=py.CreateScope();
                                    source.Execute(scope);
                                    //py.Execute(src, scope);
                                    //py.ExecuteFile(outputpath); 

    • Moved by CoolDadTx Tuesday, September 19, 2017 1:58 PM Third party product
    Tuesday, September 19, 2017 3:18 AM

All replies

  • IronPython is not support in the MSDN forums. Please post your question in the IronPython forums.
    Tuesday, September 19, 2017 1:58 PM