Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > IPython in Emacs

Reply
Thread Tools

IPython in Emacs

 
 
Seb
Guest
Posts: n/a
 
      04-25-2013
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'

 
Reply With Quote
 
 
 
 
rusi
Guest
Posts: n/a
 
      04-25-2013
On Apr 25, 8:35*am, Seb <(E-Mail Removed)> wrote:
> 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....e757567f28368e

[Since you did not say whether you are on windows or *nix, just saying]
 
Reply With Quote
 
 
 
 
Seb
Guest
Posts: n/a
 
      04-25-2013
On Wed, 24 Apr 2013 21:38:04 -0700 (PDT),
rusi <(E-Mail Removed)> wrote:

> 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....e757567f28368e


On Debian here, so not a problem.

Thanks,
--
Seb

 
Reply With Quote
 
rusi
Guest
Posts: n/a
 
      04-25-2013
On Apr 25, 6:01*pm, Seb <(E-Mail Removed)> wrote:
> On Wed, 24 Apr 2013 21:38:04 -0700 (PDT),
>
> rusi <(E-Mail Removed)> wrote:
> > 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....thread/thread/...

>
> 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?
 
Reply With Quote
 
Seb
Guest
Posts: n/a
 
      04-25-2013
On Thu, 25 Apr 2013 06:54:33 -0700 (PDT),
rusi <(E-Mail Removed)> wrote:

> On Apr 25, 6:01┬*pm, Seb <(E-Mail Removed)> wrote:
>> On Wed, 24 Apr 2013 21:38:04 -0700 (PDT),


>> rusi <(E-Mail Removed)> wrote:
>> > 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....thread/thread/...


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


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'.


--
Seb

 
Reply With Quote
 
rusi
Guest
Posts: n/a
 
      04-26-2013
On Apr 26, 3:18*am, Seb <(E-Mail Removed)> wrote:
>
> 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
)


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ipython -wthread vs. ipython -pylab Wolfram Brenig Python 0 09-12-2011 03:39 PM
Pyflakes and IPython does not work for Emacs on Windows? Dsrt Egle Python 5 09-30-2010 09:06 PM
ipython / vs \ in readline on MS Windows (and ipython help grepper) bdb112 Python 2 03-12-2009 05:34 PM
ipython + gnu emacs on windows madhusub@gmail.com Python 0 09-08-2005 11:46 PM
Re_: Best way to run ipython inside of emacs shell? Yaroslav Bulatov Python 1 08-03-2004 05:14 PM



Advertisments