简体   繁体   English

Python Jupyter:`%run -d`(调试模式)不起作用

[英]Python Jupyter: `%run -d` (debug mode) doesn't work

I am trying to run a script in a Jupyter Notebook in debug mode with the magic %run -d "/home/dev/filename.py" .我正在尝试使用魔术%run -d "/home/dev/filename.py"在调试模式下在 Jupyter Notebook 中运行脚本。

I receive error : AttributeError: 'NoneType' object has no attribute 'f_globals' when doing so.我收到错误: AttributeError: 'NoneType' object has no attribute 'f_globals'这样做时。

This would happen with filename.py containing only print("hello world) . The script itself is irrelevant and the error happens on calling the magic.这会发生在filename.py只包含print("hello world) 。脚本本身无关紧要,错误发生在调用魔法时。

To be clear the code that produces the error is the magic %run -d itself.要清楚产生错误的代码是神奇的%run -d本身。 You can try to reproduce it in a Jupyter Notebook with any script.您可以尝试使用任何脚本在 Jupyter Notebook 中重现它。 For me any script returns that error.对我来说,任何脚本都会返回该错误。

Anyone has experienced the same?有没有人经历过同样的事情? Any idea what is happening?知道发生了什么吗?

Ok I found it: https://github.com/ipython/ipython/pull/10030 https://github.com/takluyver/ipython/commit/6b1960d811d25e8f754324259a5b4fd59f8f8162好的,我找到了: https : //github.com/ipython/ipython/pull/10030 https://github.com/takluyver/ipython/commit/6b1960d811d25e8f754324259a5b4fd59f8f8162

I t was a bug in the Ipython file that i had to manually edit.我不得不手动编辑 Ipython 文件中的一个错误。 Not the easiest for a newbie :S.对于新手来说不是最简单的:S。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM