Calling python script from


Category: .Net Core 3 Tags: Python 3

Hi Can any one help me the below scenario

 

  I have python script installed in my system (python 3).

 

  I have a web application(.netcore3.1)  with my sql.

 

 

 

   Now i need to call the script from web application, when call script from web we need to provide 3 arguments 1)input folder, 2)dbfile folder(excel file), 3)output folder.

 

 

 

I got ironpython from nuget 2.7.10 and written the below code.

 

            ScriptEngine engine = Python.CreateEngine();

 

            var searchPaths = engine.GetSearchPaths();

 

            searchPaths.Add(@"C: \Users\Jeyanthi\AppData\Local\Programs\Python");

 

            searchPaths.Add(@"C:\Users\Jeyanthi\AppData\Local\Programs\Python\Python38-32");

 

            searchPaths.Add(@"C:\Users\Jeyanthi\AppData\Local\Programs\Python\Python38-32\Lib");

 

            searchPaths.Add(@"C: \Users\Jeyanthi\AppData\Local\Programs\Python\Python38-32\DLLs");

 

            searchPaths.Add(@"C: \Users\Jeyanthi\AppData\Local\Programs\Python\Python38-32\Lib");

 

            searchPaths.Add(@"C:\Users\Jeyanthi\AppData\Local\Programs\Python\Python38-32\Scripts");

 

            searchPaths.Add(@"C:\Users\Jeyanthi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bpmn_tc_generator-1.2-py3.8.egg\bpmn_tc_generator");

 

            searchPaths.Add(@"C:\jeyanthi\bpmn_tc_generator\bpmn_tc_generator");

 

            engine.SetSearchPaths(searchPaths);

 

            var mainfile = @"C:\Users\Jeyanthi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bpmn_tc_generator-1.2-py3.8.egg\bpmn_tc_generator\run.py";

 

            ScriptScope scope = engine.CreateScope();

 

            scope.SetVariable("var1", " -e C:/jeyanthi/files -d C:/jeyanthi/DBFiles -o C:/jeyanthi/Output");

 

            engine.CreateScriptSourceFromFile(mainfile).Execute(scope);  //getting error in this line

 

Please refer the attached screenshot.

 

Thanks and Regards

Jeyanthi

 

 

 

 

Desciption
Fig 1: Caption



 

           

 

 

 


Like 0 People
Asked about 11 days ago
Jeyanthi

Jeyanthi
Atricles: 0
Questions: 1
Given Best Solutions: 0 *

Answers:

No Comments Yet

You are not loggedin, please login or signup to add comments:

Existing User

Login via:

New User



x