Is it possible to use the IPython shell from an existing Python shell, as a shell-inside-a-shell, similarly to the built-in code.interact()
?
Asked
Active
Viewed 2,168 times
21

Ram Rachum
- 84,019
- 84
- 236
- 374
3 Answers
23
In IPython 0.11 the API has been overhauled and the shell is even easier to invoke:
import IPython
IPython.embed()

yac
- 331
- 2
- 4
3
The recommended way of embedding IPython works fine:
~ $ python
Python 2.7 [...]
>>> from IPython.Shell import IPShellEmbed
>>> ipshell = IPShellEmbed()
>>> ipshell()
In [1]:

snapshoe
- 13,454
- 1
- 24
- 28
1
Django manage.py shell
invoke a IPython shell when possible, and it's implemented like this:
import IPython
shell = IPython.Shell.IPShell()
shell.mainloop()

satoru
- 31,822
- 31
- 91
- 141