Redwood
Redwood

Reputation: 69372

How do I use IPython as my Emacs Python interpreter?

I'm running Emacs 22.1.1 and IPython 0.9.1 on OS X and I'd like to be able to run lines/methods/snippets of Python code from my current buffer on demand inside an IPython interpreter.

What do I need to do to get this working?

Upvotes: 11

Views: 6031

Answers (3)

Andreas Röhler
Andreas Röhler

Reputation: 4804

python-mode.el supports IPython natively.

Just make sure shebang doesn't point to another interpreter.

In this case:

  • either call a command with ending "-ipython", which will override shebang
  • customize "ipython" as default interpreter and set `py-force-py-shell-name-p'. This might be done also via menu Python/.../Switches

Upvotes: 0

yeeking
yeeking

Reputation: 988

This version of emacs for mac:

http://emacsformacosx.com

comes with package.el pre-installed. This allows you to automatically install emacs packages. There is a package called ein:

http://tkf.github.io/emacs-ipython-notebook/

which makes it easy to interact with ipython from emacs (including notebooks).

However, as of version 24.3 of the emacs above, ein is not in the default package repository. If you add more repositories, as per:

http://www.emacswiki.org/emacs/ELPA

i.e., add this to your ~/.emacs file:

(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
                     ("marmalade" . "http://marmalade-repo.org/packages/")
                     ("melpa" . "http://melpa.milkbox.net/packages/")))

then call

M-x package-refresh-contents

you will now be able to add ein with:

M-x package-install <ret> ein

alas the MELPA version of ein does not work with ipython > 1.x so if you are using ipython 2.x, you need a newer build of ein:

https://github.com/tkf/emacs-ipython-notebook/issues/137

so clone that:

git clone https://github.com/millejoh/emacs-ipython-notebook.git

copy the lisp sub directory somewhere sensible:

cp -r emacs-ipython-notebook/lisp ~/.emacs.d/einv2

then add it to your emacs load path and load it, by adding this to your ~/.emacs:

(add-to-list 'load-path "~/.emacs.d/einv2")
  (require 'ein)

finally, get rid of the old ein, which will leave the dependencies in place:

M-x package-list-packages

scroll to ein in the package list, then:

M-x package-menu-mark-delete
M-x package-menu-execute

Restart emacs and you can connect to your ipython notebook server:

M-x ein:notebooklist-open

Upvotes: 4

RichieHH
RichieHH

Reputation: 2123

also ipython wont load with the official python.el being used with emacs 23.1.1

Upvotes: 4

Related Questions