Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 504
Lawrence Johnston Avatar asked Dec 03 '08 17:12

Lawrence Johnston


2 Answers

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

like image 133
RichieHH Avatar answered Oct 02 '22 03:10

RichieHH


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
like image 44
yeeking Avatar answered Oct 02 '22 01:10

yeeking