我目前正在建设中的C#程序将调用函数中提供的Python脚本文件。
其中一些脚本文件调用 _getframe()
在 SYS
,这会导致错误:
I'm currently building a program in C# which will call functions in provided python script files.
Some of these script files calls _getframe()
in sys
, which results in the error:
System.MissingMemberException:'模块'对象有没有属性 _getframe
System.MissingMemberException: 'module' object has no attribute '_getframe'
(因为IronPython的不具有 _getframe
默认激活。)
(Since IronPython doesn't have _getframe
activated by default.)
我已经做了google搜索了不少,发现了可以在 ipy.exe
激活它通过提供 -X:帧
作为命令行选项,但是这并没有解决我的问题,因为我没有直接使用 ipy.exe
执行蟒蛇code 。
I have done quite a lot of googling and found out that you can activate it in ipy.exe
by providing -X:Frames
as a command line option, however this doesn't solve my problem since I'm not directly using ipy.exe
to execute the python code.
在this螺纹他们提到从源代码的命令行选项重建IronPython的,我下载的源文件,但不知道如何使用这些选项构建它。 此外,他们提到的选项是在正式安装,我已经运行安装程序exe文件几次,但还没有看到有这些选项的一瞥。
In this thread they mention rebuilding IronPython from source with the command line options, I downloaded the source files but have no idea how to build it with those options. Also they mention that the options are in the official installer, I have run the installer exe several times but haven't seen a glimpse of those options there.
推荐答案
在创建PythonEngine你可以传递一个选项字典;你只需要设置帧和/或FullFrames键在字典中,以真
:
When creating the PythonEngine you can pass a dictionary of options; you just need to set the "Frames" and/or "FullFrames" keys in the dictionary to true
:
var options = new Dictionary<string, object>();
options["Frames"] = true;
options["FullFrames"] = true;
ScriptEngine engine = Python.CreateEngine(options);
如果你不想FullFrames,就这么走了出来,或将其设置为假
。
If you don't want FullFrames, just leave it out or set it to false
.
相关推荐
最新文章