21

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()?

3 Answers 3

23

In IPython 0.11 the API has been overhauled and the shell is even easier to invoke:

import IPython

IPython.embed()
Sign up to request clarification or add additional context in comments.

Comments

3

The recommended way of embedding IPython works fine:

~ $ python
Python 2.7 [...]
>>> from IPython.Shell import IPShellEmbed
>>> ipshell = IPShellEmbed()
>>> ipshell()

In [1]: 

Comments

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()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.