tags:

views:

42

answers:

2

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?

A: 

Your question looks similar to this one: http://stackoverflow.com/questions/2358731/cant-import-numpy-into-embedded-ironpython-engine

But, maybe you should give more info about what errors you got...

digEmAll
But his question seems not be solved...
Begtostudy
Have you tried to check your paths, as suggested in the link ?
digEmAll
@digEmAll :I run "test.py" with "ipy.exe -X:Frames". It's OK, no problems. So I think it is Frames setup problem.
Begtostudy
+1  A: 

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.

Dino Viehland
Begtostudy
@Dino Viehland:You should change "*.rar_" to "*.rar" of the file name.
Begtostudy