我试图使用IronPython在.net应用程序中运行一个简单的python脚本。我已经在项目中安装了nuget包(我没有在我的机器上安装ironpythoncli),并编写了以下代码来处理设置路径、读取输出和设置输入。在this.engine = Python.CreateEngine();
this.scope = this.engine.CreateScope();
this.streamOut = new MemoryStream();
this.streamErr = new MemoryStream();
this.engine.Runtime.IO.SetOutput(this.streamOut, Encoding.Default);
this.engine.Runtime.IO.SetErrorOutput(this.streamErr, Encoding.Default);
// this is a locally set environment variable
string pythonRootPath = Environment.GetEnvironmentVariable("PythonPath");
ICollection searchPaths = engine.GetSearchPaths();
searchPaths.Add($@"{pythonRootPath}\Lib\site-packages\");
searchPaths.Add($@"{pythonRootPath}\Lib");
engine.SetSearchPaths(searchPaths);
this.engine.Execute(@"import jinja2");
执行脚本会导致以下异常
^{