如何修复 IPython 的“ImportError:没有名为 shell 的模块”错误

2024-02-05

我看到很多人建议我使用以下代码片段来嵌入 IPython shell 或从例如 中删除到 IPython shell。 Django 视图。

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

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

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

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


解决办法是使用以下内容 http://ipython.org/ipython-doc/dev/interactive/reference.html#embedding-ipython反而:

import IPython
IPython.embed()

第286期 https://github.com/ipython/ipython/issues/286 on the IPython github 存储库 https://github.com/ipython/ipython/解释说 Shell 模块已移动并且应该不再使用 https://github.com/ipython/ipython/issues/286#issuecomment-835523.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何修复 IPython 的“ImportError:没有名为 shell 的模块”错误 的相关文章

随机推荐