emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] python :session does return


From: Nick Dokos
Subject: Re: [O] python :session does return
Date: Tue, 14 Jan 2014 12:55:45 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Ken Mankoff <address@hidden> writes:

> On Tue, Jan 14, 2014 at 11:32 AM, Nick Dokos <address@hidden> wrote:
>
>     Ken Mankoff <address@hidden> writes:
>    
>     > On Tue, 14 Jan 2014, Ken Mankoff wrote:
>     >>
>     >> I've seen various historical issues with :session but it seems I may 
> have a
>     >> different problem. This is the latest org in emacs 24.3. If I do not 
> have
>     >> :session, then everything works just fine.
>     >>
>     >> If I C-c C-c in the following code:
>     >>
>     >> #+BEGIN_SRC python :session transect
>     >> import numpy as np
>     >> x = np.arange(12)
>     >> #+END_SRC
>     >>
>     >> Emacs hangs the first time with minibuffer message of "Sent
>     >> python-eldoc-setup-code". If I C-g, I can edit the org buffer again. 
> All
>     >> other invocations of that code and the minibuffer message is "executing
>     >> Python code block...", but still emacs hangs until I C-g.
>     >>
>     >
>     >
>     > Hmm. If I run IPython instead of regular python by setting this:
>     > (setq org-babel-python-command "ipython --pylab --pdb --nosep")
>     >
>     > Then org does not hang. It returns as expected.
>     >
>     > In Org, the following:
>     >
>     > #+begin_src python :session foo
>     > x = 42
>     > print x
>     > #+end_src
>     >
>     > Produces no RESULTS, and in the Python *foo* buffer I see:
>     >
>     > In [8]: x = 42
>     > In [9]: print x
>     > 42
>     > In [10]: 
> open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrc0000gn/T/babel-35562TZV/python-3$
>     > In [11]: 'org_babel_python_eoe'
>     > Out[11]: 'org_babel_python_eoe'
>     >
>     >
>     > But if I remove the "print" statment in Org:
>     >
>     > #+begin_src python :session foo
>     > x = 42
>     > x
>     > #+end_src
>     >
>     > Then the RESULTS shows me 42, and the Python *foo* buffer is:
>     >
>     > In [12]: x = 42
>     > In [13]: x
>     > Out[13]: 42
>     > In [14]: 
> open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrc0000gn/T/babel-35562TZV/python-3$
>     > In [15]: 'org_babel_python_eoe'
>     > In [15]: Out[15]: 'org_babel_python_eoe'
>    
>     I believe that's the expected behaviour: the defaults value of :results
>     for python (and most other) source blocks is "value" and the print 
> statement has no
>     value. If you want the output to appear in the results, try :results 
> output.
>
> Nope. If I don't use IPython, everything hangs regardless of :results.
> When I do use IPython, ":results output" doesn't show "print" statement. 
> The plain "x" showing up in the output goes away if I use ":results output".
>

I'm not talking about the hang: that's a problem (although I can't
reproduce it, so it may -or may not - be a problem with your particular
setup.)

I was specifically addressing this comment:

> However, the capturing of output doesn't seem to work right.

Nick





reply via email to

[Prev in Thread] Current Thread [Next in Thread]