问题

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: 'module' object has no attribute

'_getframe'

(Since IronPython doesn't have _getframe activated by default.)

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.

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.

回答1:

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();

options["Frames"] = true;

options["FullFrames"] = true;

ScriptEngine engine = Python.CreateEngine(options);

If you don't want FullFrames, just leave it out or set it to false.

回答2:

A little out of the scope of the question, but meant for anyone else getting this error by invoking a Python script using the ipy.exe interpreter directly.

You can just add the argument -X:FullFrames. So for example invoke the script like

ipy.exe -X:FullFrames script.py

来源:https://stackoverflow.com/questions/6997832/ironpython-sys-getframe-not-found

ironpython this_IronPython sys._getframe not found相关推荐

  1. python中使用sys模板和logging模块获取行号和函数名的方法

    From: http://www.jb51.net/article/49026.htm 这篇文章主要介绍了python中使用sys模板和logging模块获取行号和函数名的方法,需要的朋友可以参考下 ...

  2. python中append函数合并列表且列表内数字从高到低_35个高级Python知识点总结

    No.1 一切皆对象 众所周知,Java中强调"一切皆对象",但是Python中的面向对象比Java更加彻底,因为Python中的类(class)也是对象,函数(function) ...

  3. python内置collections模块的使用

    python内置collections模块的使用 文章目录: 一.collections模块说明 1.查看collections模块的定义路径 2.查看collections文档介绍信息 3.查看co ...

  4. 流畅的python第一章_《流畅的Python》第一章学习笔记

    一摞python风格的纸牌from collections import namedtuple Card = namedtuple('Card', ['rank', 'suit']) # 构建只有少数 ...

  5. python查找指定字符所在行号_在python中获取当前位置所在的行号和函数名

    对于python,这几天一直有两个问题在困扰我: 1.python中没办法直接取得当前的行号和函数名.这是有人在论坛里提出的问题,底下一群人只是在猜测python为什么不像__file__一样提供__ ...

  6. [转]35个高级Python知识点总结

    No.1 一切皆对象 众所周知,Java中强调"一切皆对象",但是Python中的面向对象比Java更加彻底,因为Python中的类(class)也是对象,函数(function) ...

  7. 《流畅的Python》第一章学习笔记

    一摞python风格的纸牌 from collections import namedtupleCard = namedtuple('Card', ['rank', 'suit']) # 构建只有少数 ...

  8. python重要知识点_35个高级Python知识点总结

    No.1 一切皆对象 众所周知,Java中强调"一切皆对象",但是Python中的面向对象比Java更加彻底,因为Python中的类(class)也是对象,函数(function) ...

  9. python获取行号_在python中获取当前位置所在的行号和函数名

    python中没办法直接取得当前的行号和函数名.这是有人在论坛里提出的问题,底下一群人只是在猜测python为什么不像__file__一样提供__line__和__func__,但是却最终也没有找到解 ...

最新文章

  1. java拍照搜题软件下载_修改版|学生福利!!免费拍照搜题秒出答案,扫一扫作业出答案!...
  2. ecshop的Mysql操作类
  3. cudnn.benchmark
  4. 使用Pytorch从零搭建高精准度实时目标检测框架
  5. 初步理解Python进程的信号通讯
  6. 经典的异或题:只出现一次的数字
  7. 软考高项之范围管理-攻坚记忆
  8. left join 临时表_不懂SQL优化?那你就OUT了——表连接的优化
  9. STM32 MDK常见错误与解决
  10. 【log4net】配置文件
  11. SpringMVC中异常捕获
  12. java获取年份getyear_Java LocalDateTime getYear()用法及代码示例
  13. 【最强宝典】后端面试知识点合集
  14. 自己动手写操作系统——开发环境搭建
  15. javascript 建模_使用JavaScript进行快速数据建模
  16. dell台式机进入安全模式_戴尔电脑如何进入安全模式?
  17. Miles to go ... - Arun Gupta: Securing WebSocket using wss and HTTPS/TLS (Tech T
  18. 2022年,英文科技论文写作与学术报告期末考试答案(仅供参考)
  19. 戴尔刀片服务器型号在哪里,戴尔 PowerEdge M640 刀片式服务器:服务器 | Dell 中国大陆...
  20. 想知道有哪些缩小视频大小的软件?这几个压缩软件你该知道

热门文章

  1. 面试官问你MyBatis中有哪些设计模式,把这篇文章发给他
  2. 写给程序员的裁员防身指南
  3. Directory /opt/jfrog/artifactory/var has bad permissions for user id 1030
  4. linux CentOS7 erlang安装
  5. Linux Shell脚本专栏_Linux系统发送告警邮件脚本_02
  6. mysql遇见Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre的问题
  7. idea全局搜索快捷鍵ctrl+shift+F失效
  8. vue Draggable实现拖动改变顺序
  9. Android 控件 - TextView
  10. python遗传算法计算实例_遗传算法python简单例子(详解)