我有 Visual Studio 2013,我的主要表单是用 C# 编写的。我有一个具有许多功能的 python(3.7) 脚本(使用 Pandas、Numpy 等库)
如何使用 Iron python 从我的 C#.net 代码中调用 Python 函数?即在来自.net UI的特定事件上,应该调用python脚本并将值作为参数从python返回到.net,反之亦然
- 试过铁蟒
- Powershell 从 .net 调用 python 脚本。
.Net 代码:
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
Microsoft.Dynamic.dll 中出现“IronPython.Runtime.Exceptions.ImportException”类型的未处理异常
附加信息:没有名为 pandas 的模块