From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ken Mankoff Subject: Re: python :session does return Date: Tue, 14 Jan 2014 12:48:30 -0500 Message-ID: References: <87lhyi5xt1.fsf@alphaville.bos.redhat.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e01160600e9dfd904eff1cc1e Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W386O-000802-T5 for emacs-orgmode@gnu.org; Tue, 14 Jan 2014 12:48:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W386J-0006GC-PY for emacs-orgmode@gnu.org; Tue, 14 Jan 2014 12:48:36 -0500 Received: from mail-ob0-x229.google.com ([2607:f8b0:4003:c01::229]:42036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W386J-0006G7-Hy for emacs-orgmode@gnu.org; Tue, 14 Jan 2014 12:48:31 -0500 Received: by mail-ob0-f169.google.com with SMTP id wp4so4150740obc.0 for ; Tue, 14 Jan 2014 09:48:30 -0800 (PST) In-Reply-To: <87lhyi5xt1.fsf@alphaville.bos.redhat.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nick Dokos Cc: Org-mode --089e01160600e9dfd904eff1cc1e Content-Type: text/plain; charset=ISO-8859-1 On Tue, Jan 14, 2014 at 11:32 AM, Nick Dokos wrote: > Ken Mankoff 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. However, the > > capturing of output doesn't seem to work right. > > > > 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". -k. --089e01160600e9dfd904eff1cc1e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

= On Tue, Jan 14, 2014 at 11:32 AM, Nick Dokos <ndokos@gmail.com> wrote:
Ken = Mankoff <mankoff@gmail.com> = 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 n= ot 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 =3D 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&quo= t;)
>
> Then org does not hang. It returns as expected. However, the
> capturing of output doesn't seem to work right.
>
> In Org, the following:
>
> #+begin_src python :session foo
> x =3D 42
> print x
> #+end_src
>
> Produces no RESULTS, and in the Python *foo* buffer I see:
>
> In [8]: x =3D 42
> In [9]: print x
> 42
> In [10]: open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrc0000gn/T/ba= bel-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 =3D 42
> x
> #+end_src
>
> Then the RESULTS shows me 42, and the Python *foo* buffer is:
>
> In [12]: x =3D 42
> In [13]: x
> Out[13]: 42
> In [14]: open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrc0000gn/T/ba= bel-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 prin= t statement has no
value. If you want the output to appear in the results, try :results output= .

Nope. If I don't use IPython, eve= rything hangs regardless of :results.
When I do use IPython, &quo= t;:results output" doesn't show "print" statement.=A0
The plain "x" showing up in the output goes away if I use &q= uot;:results output".

=A0 =A0-k.
--089e01160600e9dfd904eff1cc1e--