如何在 C# 2.0 中使用 –X:Frames 加载ironpython?
我可以使用ironpython 2.6(不适用于.net 4)加载numpy,在命令行上使用 -X:Frames 或 -X:FullFrames 运行 ipy 。
但是,如果我想在 C# 2.0 中使用 Ironpython/DLR 加载 py 文件,如何使用 -X:Frames 或 -X:FullFrames ?
我这样尝试:
var lang = Python.CreateLanguageSetup(null);
lang.Options["Frames"] = ScriptingRuntimeHelpers.True;
var setup = new ScriptRuntimeSetup();
setup.LanguageSetups.Add(lang);
var runtime = new ScriptRuntime(setup);
var engine = runtime.GetEngine("py");
engine.ExecuteFile("test.py");
但是,它不起作用! 那么,有人可以帮我吗?
I can use ironpython 2.6 (not for .net 4) load numpy, running ipy with -X:Frames or -X:FullFrames on the command line.
But, if I want to use Ironpython/DLR in C# 2.0 to load the py file, how can I use -X:Frames or -X:FullFrames?
I tried it like this:
var lang = Python.CreateLanguageSetup(null);
lang.Options["Frames"] = ScriptingRuntimeHelpers.True;
var setup = new ScriptRuntimeSetup();
setup.LanguageSetups.Add(lang);
var runtime = new ScriptRuntime(setup);
var engine = runtime.GetEngine("py");
engine.ExecuteFile("test.py");
But, it didn't work!
So, is there anyone can give me a hand?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不认为框架工作或不工作是你的问题。如果我将你的代码放入
test.py 中,如果我有 'lang.Options["Frames"] = ScriptingRuntimeHelpers.True;'如果我不这样做,就会失败。这表明该选项工作正常。
那么您遇到的错误是什么?您可能需要设置命令行通常执行的操作 - 例如 sys.path ,它可能需要当前目录和/或“.”。或者可能需要导入 site.py。或者,IronClad 可能安装在 DLL 目录中并自动加载,因此您需要对其 DLL 执行 runtime.LoadAssembly(...) 。
I don't think frames working or not working is your problem. If I take your code and put:
into test.py it works if I have the 'lang.Options["Frames"] = ScriptingRuntimeHelpers.True;' line and fails if I don't. That indicates the option is working fine.
So what is the error you're getting? It might be that you need to set something which the command line normally does - such as sys.path which maybe needs the current directory and/or ".". Or maybe site.py needs to be imported. Or maybe IronClad is installed in the DLLs directory and auto-loaded so you need to do runtime.LoadAssembly(...) on it's DLL.
您的问题看起来与此类似:
无法将 numpy 导入嵌入式 IronPython 引擎
但是,也许你应该提供有关您遇到的错误的更多信息...
Your question looks similar to this one:
Can't import numpy into embedded ironpython engine
But, maybe you should give more info about what errors you got...