In order to use IPython during Python development in Emacs, I have been opening up a terminal, and typing ipython
. This doesn't seem like the right way to do it.
For one thing, my buffer lists this buffer as *ansi-term*
, which is confusing, as I often end up with multiple terminals, one of which is dedicated to Python. I also see that I can open a python interpreter directly with M-x python-shell
. It seems like there ought to be a similar option for IPython.
Is there a better way to use the IPython interpreter in Emacs?
I'm using Emacs 24 with Prelude.
I don't know what Prelude is, but if you can install the latest Emacs (i.e, Emacs with Fabian's python-mode included), then you can use the following to let Python mode know your preferred choice of interpreter. Then you just need to call M-x run-python
:
--
(when (executable-find "ipython")
(setq python-shell-interpreter "ipython"))
--
I've tried abo-abo's approach to running ipython inside of emacs. Its a pretty slick way of shortcutting shell functions within emacs. However, you do lose emacs functionality when you are in the shell (e.g. can't M-x o
out of the shell)
Instead, I personally think that using the Emacs builtin shell command (M-x shell
) is much better. You can run ipython within the Emacs builtin shell and still have all Emacs functionality that we all know and love.
Seems a bit late, however was also having similar problem, wanted to have ipython as default python interpreter for my emacs 24.x. The following worked like a magic -
(require 'python)
(setq python-shell-interpreter "ipython")
(setq python-shell-interpreter-args "--pylab")
thanks to http://www.flannaghan.com/2013/08/29/ipython-emacs for saving my day and hopefully yours.
PS: seems having anaconda preinstalled in your system helps...
Edit: Whoops, the project below is a fork, not the official Prelude project. The second paragraph here still stands. Or you could try the fork.
It looks like Prelude already sets up ipython integration. Maybe your copy is out of date?
If M-x run-python
doesn't launch ipython, try adding (setq python-shell-interpreter "ipython")
to your init file (or just evaluating it) and running M-x run-python
again. After a quick test without Prelude that seems to be all that is necessary.
You can use my Emacs extension called emacs-ipython for this.
https://github.com/burakbayramli/emacs-ipython
In a LaTeX buffer (you can change this to be any buffer) between code blocks with one keystroke it sends the python code to ipython kernel and displays the results in a verbatim block underneath.