Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

ipython

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?

like image 464
Caspar Avatar asked Oct 12 '12 05:10

Caspar


1 Answers

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.

like image 186
Caspar Avatar answered Nov 13 '22 21:11

Caspar