【问题标题】:configure IPython using start_ipython()使用 start_ipython() 配置 IPython
【发布时间】:2014-05-30 19:33:53
【问题描述】:

当我使用一个普通的 python shell(我希望这个术语是可以理解的)然后输入

import IPython
IPython.start_ipython(["--pylab=qt", "--TerminalInteractiveShell.editor=scite"])

ipython 控制台启动就像

ipython --pylab=qt --TerminalInteractiveShell.editor=scite

但是当我在已经运行的 ipython 控制台中执行相同操作时,这不起作用。是否可以“重置”正在运行的 ipython 控制台?

编辑:我现在用自己的代码解决了我的问题。当然在这里展示我的代码对任何人都没有帮助。在给定的答案上(谢谢!):打字

%pylab qt, %
%config TerminalInteractiveShell.editor='scite'

不会抛出错误消息。但是它和

不一样
ipython --pylab=qt --TerminalInteractiveShell.editor='scite'

行为不同,我的 GUI 仅在后一种情况下响应。我不知道为什么。

【问题讨论】:

  • 您可以使用%config 魔法更改配置设置,即%config TerminalInteractiveShell.editor='scite'
  • 我看到了这些选项,但我不知道如何模仿“--pylab=qt”。我还在某处读到,必须在所有其他选项之前设置此特定选项。
  • 有一个单独的%pylab 魔法来启用 pylab 模式。使用%pylab qt 让它选择Qt 后端。

标签: python configuration ipython


【解决方案1】:

有一个 IPython 魔术命令 %reset 将清除所有变量。

您可以使用%reset?查看更多详细信息和文档字符串:

通过删除用户定义的所有名称来重置命名空间,如果 不带参数调用,或者通过删除某些类型的对象,例如 就像当前在 IPython 的 In[] 和 Out[] 容器中的所有内容(参见 详细参数)。

【讨论】:

  • 这个命令很遗憾不会重置 sys.modules。这就是我担心的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-16
  • 2018-03-04
  • 1970-01-01
相关资源
最近更新 更多