开发者

How can I use –X:Frames in C# 2.0 to load ironpython?

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 Script开发者_如何学JAVARuntime(setup); 
        var engine = runtime.GetEngine("py");

        engine.ExecuteFile("test.py");  

But, it didn't work! So, is there anyone can give me a hand?


I don't think frames working or not working is your problem. If I take your code and put:

import sys
sys._getframe()

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.


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜