How can I fix “ImportError: no module named shell” error for IPython

左心房为你撑大大i 提交于 2019-12-12 11:05:36

问题


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.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/12852887/how-can-i-fix-importerror-no-module-named-shell-error-for-ipython

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!