emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org + Elpy Python + IPython
@ 2014-05-08  2:52 Ken Mankoff
  2014-05-08  6:32 ` Puneeth Chaganti
  2014-05-20 16:47 ` Ken Mankoff
  0 siblings, 2 replies; 4+ messages in thread
From: Ken Mankoff @ 2014-05-08  2:52 UTC (permalink / raw)
  To: Org-mode mailing list; +Cc: John Kitchin


FYI Org + Elpy + IPython all play nicely now.

There have been some previous posts about people (me included) having
trouble using the full IPython stack in Org Mode. Some of those problems
were limited to when using sessions, and others only if trying to take
full advantage of the nice Python support provided by Elpy (enabled via
the (elpy-use-ipython) command).

I think the primary issue was Org text analysis on the >>> prompt which
in IPython becomes "In [n]:". This is solved with the "--classic" flag
to ipython.

With this setup:

(setq org-babel-python-command "ipython --pylab=qt4 --pdb --nosep --classic --no-banner --no-confirm-exit")

I now have Org, Python, IPython, and Elpy (including (elpy-use-ipython))
all running together in session and non-session mode.

  -k.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Org + Elpy Python + IPython
  2014-05-08  2:52 Org + Elpy Python + IPython Ken Mankoff
@ 2014-05-08  6:32 ` Puneeth Chaganti
  2014-05-20 16:47 ` Ken Mankoff
  1 sibling, 0 replies; 4+ messages in thread
From: Puneeth Chaganti @ 2014-05-08  6:32 UTC (permalink / raw)
  To: Ken Mankoff; +Cc: Org-mode mailing list, John Kitchin

On Thu, May 8, 2014 at 8:22 AM, Ken Mankoff <mankoff@gmail.com> wrote:
> I now have Org, Python, IPython, and Elpy (including (elpy-use-ipython))
> all running together in session and non-session mode.


Awesome.  Thanks for sharing!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Org + Elpy Python + IPython
  2014-05-08  2:52 Org + Elpy Python + IPython Ken Mankoff
  2014-05-08  6:32 ` Puneeth Chaganti
@ 2014-05-20 16:47 ` Ken Mankoff
  2014-05-20 20:23   ` Ken Mankoff
  1 sibling, 1 reply; 4+ messages in thread
From: Ken Mankoff @ 2014-05-20 16:47 UTC (permalink / raw)
  To: Org-mode mailing list; +Cc: John Kitchin


Addendum to this old thread:

On 2014-05-07 at 22:52, Ken Mankoff <mankoff@gmail.com> wrote:
> FYI Org + Elpy + IPython all play nicely now.
>
> There have been some previous posts about people (me included) having
> trouble using the full IPython stack in Org Mode. Some of those
> problems were limited to when using sessions, and others only if
> trying to take full advantage of the nice Python support provided by
> Elpy (enabled via the (elpy-use-ipython) command).
>
> I think the primary issue was Org text analysis on the >>> prompt which
> in IPython becomes "In [n]:". This is solved with the "--classic" flag
> to ipython.
>
> With this setup:
>
> (setq org-babel-python-command "ipython --pylab=qt4 --pdb --nosep --classic --no-banner --no-confirm-exit")
>
> I now have Org, Python, IPython, and Elpy (including
> (elpy-use-ipython)) all running together in session and non-session
> mode.

ipython --classic appears to let IPython work properly with Org, but it
does not. There are some nefarious bugs. For example, the second
indented for loop (foo, bar) never runs if the interpreter is "ipython
--classic", but runs properly for "python".

for n in [1,2]:
    print n
    for a in ['a','b']:
        print a

    for f in ['foo','bar']:
        print f

It appears that IPython munges empty lines differently than python. I've
tried the " --no-autoindent" and "--no-pprint" and the blank line still
causes problems. Anyway, I recommend sticking with plain Python which
works in all code I've tried both session and non-session.

  -k.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Org + Elpy Python + IPython
  2014-05-20 16:47 ` Ken Mankoff
@ 2014-05-20 20:23   ` Ken Mankoff
  0 siblings, 0 replies; 4+ messages in thread
From: Ken Mankoff @ 2014-05-20 20:23 UTC (permalink / raw)
  To: Org-mode mailing list


And with a bit more work (and help from others) I have it working.

IPython, Org, Elpy, session or no-session. Still cannot set
(elpy-use-ipython) which makes the IPython sessions a bit less awesome
(no popup help, for example). But everything else appears to work.

(setq org-babel-python-command "ipython --pylab=osx --pdb --nosep --classic --no-banner --no-confirm-exit")

;; https://github.com/jorgenschaefer/elpy/issues/191
;; https://lists.gnu.org/archive/html/emacs-orgmode/2014-03/msg00405.html
;; make IPython work w/ Org
(defadvice org-babel-python-evaluate
  (around org-python-use-cpaste
	  (session body &optional result-type result-params preamble) activate)
  "Add a %cpaste and '--' to the body, so that ipython does the right thing."
  (setq body (concat "%cpaste -q\n" body "\n--\n"))
  ad-do-it
  (if (stringp ad-return-value)
      (setq ad-return-value (replace-regexp-in-string "\\(^Pasting code; enter '--' alone on the line to stop or use Ctrl-D\.[\r\n]:*\\)" ""
						      ad-return-value))))


 -k.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-05-20 20:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-08  2:52 Org + Elpy Python + IPython Ken Mankoff
2014-05-08  6:32 ` Puneeth Chaganti
2014-05-20 16:47 ` Ken Mankoff
2014-05-20 20:23   ` Ken Mankoff

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).