2

コマンドラインで -X:Frames または -X:FullFrames を指定して ipy を実行し、ironpython 2.6 (.net 4 用ではない) load numpy を使用できます。

しかし、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");  

しかし、それはうまくいきませんでした!それで、誰か私に手を貸してくれる人はいますか?

4

2 に答える 2

1

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.

于 2010-07-01T05:02:45.787 に答える
0

あなたの質問は次のようなものです: Can't import numpy into embedded ironpython engine

しかし、おそらく、どのようなエラーが発生したかについてもっと情報を提供する必要があります...

于 2010-06-30T07:49:26.463 に答える