IronPython的sys._getframe未找到 [英] IronPython sys._getframe not found

查看:1020
本文介绍了IronPython的sys._getframe未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在建设中的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.

在<一个href="http://stackoverflow.com/questions/3780379/how-can-i-enable-sys-getframe-in-ironpython-2-6-1">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.

这篇关于IronPython的sys._getframe未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆