【发布时间】:2011-07-24 21:25:52
【问题描述】:
在切换到 IPython v0.11(使用 Python 2.6.1)之前,可以使用例如 this 嵌入交互式 IPython shell,例如
from IPython.Shell import IPShellEmbed
ipshell = IPShellEmbed()
ipshell() # this call anywhere in your program will start IPython
“嵌入式外壳已经被重构为一个真正独立的 InteractiveShell 子类,称为 InteractiveShellEmbed。所有嵌入逻辑都已从基类中取出并放入嵌入式子类”(参见here 和here)。
按照我的理解,您现在应该能够简单地通过以下方式启动控制台
import IPython
IPython.embed()
然而,这引发了
TraitError:InteractiveShellEmbed 实例的 'exit_msg' 特征必须是字符串,但指定了 u'' 的值。
如果我们通过 exit_msg 传递一个字符串
IPython.embed(exit_msg='Whatever')
然后它会引发不同的错误
AttributeError: 'InteractiveShellEmbed' 对象没有属性 'set_completer'
还有其他人遇到过这个问题吗?否则这可能是一个错误,因为它毕竟是开发者版本。
【问题讨论】: