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?

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

Sign up to request clarification or add additional context in comments.

2 Comments

I tred sys._getframe() and it's OK, and running ipy console with -X:Frames is also ok. Only load py by ironpython in C# 2.0. I uploaded my code (Visual studio 2010 solution, but .net 2.0 project):1oz7ga.blu.livefilestore.com/…
You should change ".rar_" to ".rar" of the file name.
0

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

2 Comments

Have you tried to check your paths, as suggested in the link ?
I run "test.py" with "ipy.exe -X:Frames". It's OK, no problems. So I think it is Frames setup problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.