如何修复IPython的“ImportError:no module named shell”错误

时间:2021-06-28 23:07:55

I've seen a number of people recommend that I use the following snippet to embed an IPython shell or drop to an IPython shell from e.g. a django view.

我见过很多人建议我使用下面的代码片段来嵌入一个IPython shell或者从一个IPython shell中删除一个IPython shell。一个django视图。

from IPython.Shell import IPShellEmbed
ipython = IPShellEmbed()
ipython()

But when I do this, I get

但是,当我这样做时,我得到了

>>> from IPython.Shell import IPShellEmbed
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named Shell

How can I embed IPython or start an IPython console from an existing python app?

如何嵌入IPython或从现有的python应用程序启动IPython控制台?

1 个解决方案

#1


13  

The solution is to use the following instead:

解决方案是使用以下代码:

import IPython
IPython.embed()

Issue 286 on the IPython github repo explains that the Shell module has moved and should no longer be used.

IPython github repo上的问题286解释了Shell模块已移动,不应再使用。

#1


13  

The solution is to use the following instead:

解决方案是使用以下代码:

import IPython
IPython.embed()

Issue 286 on the IPython github repo explains that the Shell module has moved and should no longer be used.

IPython github repo上的问题286解释了Shell模块已移动,不应再使用。