IPython in Emacs

Discussion in 'Python' started by Seb, Apr 25, 2013.

  1. Seb

    Seb Guest

    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'
     
    Seb, Apr 25, 2013
    #1
    1. Advertising

  2. Seb

    rusi Guest

    On Apr 25, 8:35 am, Seb <> 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.lang.python/browse_thread/thread/36e757567f28368e

    [Since you did not say whether you are on windows or *nix, just saying]
     
    rusi, Apr 25, 2013
    #2
    1. Advertising

  3. Seb

    Seb Guest

    Seb, Apr 25, 2013
    #3
  4. Seb

    rusi Guest

    On Apr 25, 6:01 pm, Seb <> wrote:
    > On Wed, 24 Apr 2013 21:38:04 -0700 (PDT),
    >
    > rusi <> 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.lang.python/browse_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?
     
    rusi, Apr 25, 2013
    #4
  5. Seb

    Seb Guest

    On Thu, 25 Apr 2013 06:54:33 -0700 (PDT),
    rusi <> wrote:

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


    >> rusi <> 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.lang.python/browse_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
     
    Seb, Apr 25, 2013
    #5
  6. Seb

    rusi Guest

    On Apr 26, 3:18 am, Seb <> 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
    )
     
    rusi, Apr 26, 2013
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yaroslav Bulatov
    Replies:
    1
    Views:
    483
    Fernando Perez
    Aug 3, 2004
  2. Replies:
    0
    Views:
    472
  3. bdb112
    Replies:
    2
    Views:
    1,188
    Jason Scheirer
    Mar 12, 2009
  4. Dsrt Egle
    Replies:
    5
    Views:
    1,137
    Dsrt Egle
    Sep 30, 2010
  5. Wolfram Brenig

    ipython -wthread vs. ipython -pylab

    Wolfram Brenig, Sep 12, 2011, in forum: Python
    Replies:
    0
    Views:
    359
    Wolfram Brenig
    Sep 12, 2011
Loading...

Share This Page