IPython in Emacs

S

Seb

Hi,

Please excuse the slightly off-topic query. I'm learning Python, using
the IPython (0.13) shell, and wanted to run it from Emacs 24. AFAICT,
python.el is the most actively developed library, and is included in
Emacs. How do experienced Python programmers set up their python.el to
make the best of it? I've done it following the recommendations given
in the library¹:

(setq
python-shell-interpreter "ipython"
python-shell-interpreter-args ""
python-shell-prompt-regexp "In \\[[0-9]+\\]: "
python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: "
python-shell-completion-setup-code
"from IPython.core.completerlib import module_completion"
python-shell-completion-module-string-code
"';'.join(module_completion('''%s'''))\n"
python-shell-completion-string-code
"';'.join(get_ipython().Completer.all_completions('''%s'''))\n")

but this may be a little outdated as it refers to IPython 0.11.

Thanks,
Seb

+--- Footnotes ---+
¹ Ignored recommended setting for `python-shell-interpreter-args'
 
R

rusi

Hi,

Please excuse the slightly off-topic query.  I'm learning Python, using
the IPython (0.13) shell, and wanted to run it from Emacs 24.  AFAICT,
python.el is the most actively developed library, and is included in
Emacs.  How do experienced Python programmers set up their python.el to
make the best of it?  I've done it following the recommendations given
in the library¹:

(setq
 python-shell-interpreter "ipython"
 python-shell-interpreter-args ""
 python-shell-prompt-regexp "In \\[[0-9]+\\]: "
 python-shell-prompt-output-regexp "Out\\[[0-9]+\\]: "
 python-shell-completion-setup-code
 "from IPython.core.completerlib import module_completion"
 python-shell-completion-module-string-code
 "';'.join(module_completion('''%s'''))\n"
 python-shell-completion-string-code
 "';'.join(get_ipython().Completer.all_completions('''%s'''))\n")

but this may be a little outdated as it refers to IPython 0.11.

Thanks,
Seb

+--- Footnotes ---+
¹ Ignored recommended setting for `python-shell-interpreter-args'

There were some ipython+emacs+windows bugs:
https://bugs.launchpad.net/ipython/+bug/290228

Last I tried nearly 2 years, they were still there
http://groups.google.com/group/comp.lang.python/browse_thread/thread/36e757567f28368e

[Since you did not say whether you are on windows or *nix, just saying]
 
R

rusi

On Debian here, so not a problem.

Ok me too :)

A quick try of your startup code did not work for me.
There is a perennial clash in emacs between python.el and python-
mode.el -- I guess its that.
Which do you use?

What are your commands for eval-buffer and start-interpreter?
 
S

Seb

Ok me too :)
A quick try of your startup code did not work for me. There is a
perennial clash in emacs between python.el and python- mode.el -- I
guess its that. Which do you use?

The first. I don't have anything python-related in ~/.emacs other than
what I showed. Works fine for me, except for weird things like multiple
input prompts in the IPython shell at startup, which seem to come from
each statement in the variables I showed. Similar things happen when
sending code from the script buffer.

What are your commands for eval-buffer and start-interpreter?

I don't understand what you're asking. I evaluate the script buffer
with `python-shell-send-buffer' and start IPython with `run-python'.
 
R

rusi

I don't understand what you're asking. I evaluate the script buffer
with `python-shell-send-buffer' and start IPython with `run-python'.


There are two emacs python modes -- one which comes builtin with emacs
-- python.el, one which (used to?) come with python -- python-mode.el.

My impression is that most pythonistas preferred the python-mode
earlier. Not so sure now.
You can get it from https://launchpad.net/python-mode/

Heres a minimal setup for python-mode +ipython (everything's probably
not working)

(add-to-list 'load-path "~/.emacs.d/downloads/python-mode") ;; Or
whatever is your path for python-mode.el
(autoload 'python-mode "python-mode" "Python Mode." t)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
(add-to-list 'interpreter-mode-alist '("python" . python-mode))

;; A first cut at replicating your settings of ipython for python-mode
(setq py-python-command "ipython" ; python-shell-interpreter
py-python-command-args '("") ; python-shell-interpreter-args
; Should it be -i?
py-shell-input-prompt-1-regexp "In \\[[0-9]+\\]: "
; Other variables dont exist or cant find
; Not really explored ipython.el
)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top