I have Visual Studio 2013 with my main form written in C#. And I have a python(3.7) script with many functions (using libraries like Pandas, Numpy etc.)
How do I call the Python functions from my C#.net code using iron python? i.e. on a particular event from .net UI, the python script should be called and return the value as a parameter from python to .net and vice versa
- Tried Iron python
- Powershell to call the python script from .net.
.Net Code:
using Microsoft.Scripting.Hosting;
using IronPython.Hosting;
using IronPython.Runtime.Types;
using IronPython.Modules;
ScriptEngine py = IronPython.Hosting.Python.CreateEngine();
ScriptScope scope = py.ExecuteFile("Square.py");
dynamic Excel1 = scope.GetVariable("Excel")();
Excel1.ReadExcel("C:\\filePath\\abc.xlsx");
Python Script:
class Excel:
def ReadExcel(self, Path):
import pandas as pd
df = pd.read_excel (Path)
print (df)
return df
An unhandled exception of type 'IronPython.Runtime.Exceptions.ImportException' occurs in Microsoft.Dynamic.dll
Additional information: No module named pandas