Re: [O] python :session does return

2014-01-16 Thread Ken Mankoff

Hi John,

On Wed, 15 Jan 2014, John Hendy wrote:


On Wed, Jan 15, 2014 at 6:22 AM, Ken Mankoff mank...@gmail.com wrote:
Are my results contrary to what's been happening to you?


Actually things now seem to be working.  All cases. No hanging when I
run Python in a session, and return and print work when running
IPython. I wrote a test example, load it with emacs -q and then load a
minimal org setup in a code block (I think I'm just starting to get
the hang of some basic lisp and tangling code in Org). I've tried all
possible cases (yes/no session, and results of default/output/value)
and it all seems to be working. I then repeated it all with IPython
instead of default Python.

Output results are a bit ugly when using IPython. If I get a chance
I'll look into the code. Since regular python output doesn't print the
startup info, I assume the same can be done for IPython. It should
just ignore everything until the first In [1]: text appears.

Perhaps the previous issues were due to a complicated org setup.

Test file follows.

Cheers,

  -k.


* Intro


This is a test file for Python + Emacs. I'm loading this file running
emacs -q test.org to try to simplify the setup

** Setup For running Python and other stuff
#+BEGIN_SRC emacs-lisp
(setq org-confirm-babel-evaluate nil) ;; don't ask to eval code
(org-babel-do-load-languages
 'org-babel-load-languages
 '((python . t)
   (sh . t)
   (emacs-lisp . t)
))
#+END_SRC

#+RESULTS:
| (python . t) | (sh . t) | (emacs-lisp . t) |

** System setup:
#+BEGIN_SRC sh :results output
/usr/local/bin/emacs --version
uname -a
python -V # no ouput for some reason...
# Python 2.7.3 --  64-bit
#+END_SRC

#+RESULTS:
: GNU Emacs 24.3.1
: Darwin 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; 
xnu-2422.1.72~6/RELEASE_X86_64 x86_64

* Testing

There are two tests per :output and per :session option. 
1. 'foo' equal to 'print foo'

2. 'print foo'.

** No Session
 No Session, No Results
#+BEGIN_SRC python
print 'No Session, No Result'
#+END_SRC
#+RESULTS:
: None

#+BEGIN_SRC python
return 'No Session, No Result'
#+END_SRC
#+RESULTS:
: No Session, No Result


 No Session, Result Output
#+BEGIN_SRC python :results output
print 'No Session, Result Output'
#+END_SRC
#+RESULTS:

*Warning: Does not run*
#+BEGIN_SRC python :results output
return 'No Session, Result Output'
#+END_SRC
#+RESULTS:

 No Session, Result Value
#+BEGIN_SRC python :results value
print 'No Session, Result Value'
#+END_SRC
#+RESULTS:
: None

#+BEGIN_SRC python :results value
return 'No Session, Result Value'
#+END_SRC
#+RESULTS:
: No Session, Result Value



** Yes Session
 Yes Session, No Results
#+BEGIN_SRC python :session foo
print 'No Session, No Result'
#+END_SRC
#+RESULTS:
: None

#+BEGIN_SRC python :session foo
return 'No Session, No Result'
#+END_SRC
#+RESULTS:
: No Session, No Result

 Yes Session, Result Output
#+BEGIN_SRC python :results output :session foo
print 'No Session, Result Output'
#+END_SRC
#+RESULTS:


*Warning: Does not run*
#+BEGIN_SRC python :results output :session foo
return 'No Session, Result Output'
#+END_SRC
#+RESULTS:


 Yes Session, Result Value
#+BEGIN_SRC python :results value :session foo
print 'No Session, Result Value'
#+END_SRC
#+RESULTS:
: None

#+BEGIN_SRC python :results value :session foo
return 'No Session, Result Value'
#+END_SRC
#+RESULTS:
: No Session, Result Value



* Second Try with IPython

Execute the following and re-run the test code above.
#+BEGIN_SRC emacs-lisp
(setq org-babel-python-command ipython --pylab --pdb --nosep)
#+END_SRC
#+RESULTS:
: ipython --pylab --pdb --nosep




Re: [O] python :session does return

2014-01-15 Thread Ken Mankoff
Hi John,

Yes, you and others in that thread seem to be experiencing the same
problem, although there are also different issues discussed there.

I'm a bit surprised... With the popularity of python I would expect more
org users to have run into this and it to be fixed, but perhaps it isn't as
widely used as I thought. Anyway, it is now usable even if the 'print'
statements don't show up.

  -k.



On Tue, Jan 14, 2014 at 6:04 PM, John Hendy jw.he...@gmail.com wrote:

 On Tue, Jan 14, 2014 at 7:38 AM, Ken Mankoff mank...@gmail.com 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.
 

 This sounded familiar to me, so I googled around for Org mailing list
 discussions I was involved in related to python. Does this shed any
 new light?
 - https://www.mail-archive.com/emacs-orgmode@gnu.org/msg68542.html

 Seems that the discussion ended with the possibility that it was an
 emacs change to python.el, and not related to Org, but I'm not sure if
 any actions were ever taken regarding that. In any case, the
 discussion features a discrepancy between python behavior with
 `:session name` and without, so it seemed like a possible candidate to
 pass along!



 Best regards,
 John

  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.
 
  If I look at the *transect* buffer, I see the following. The code runs
 just
  fine, but for some reason it does not return.
 
-k.
 
 
 
  Enthought Canopy Python 2.7.3 | 64-bit | (default, Dec  2 2013, 16:19:29)
  [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
  Type help, copyright, credits or license for more information.
  import numpy as np
  Start .pythonrc
  End .pythonrc
 
  import numpy as np
 
  x = np.arange(12)
  x = np.arange(12)
 
 
 
 open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022Yjm',
  'w').write(str(_))
 
 open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022Yjm',
  'w').write(str(_))
 
 
 
 
  'org_babel_python_eoe'
  'org_babel_python_eoe'
 
   Traceback (most recent call last):
 
File stdin, line 1, in module
  NameError: name '_' is not defined
 
'org_babel_python_eoe'
  import numpy as np
 
  import numpy as np
  x = np.arange(12)
 
  x = np.arange(12)
 
 
 
 
 open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022lts',
  'w').write(str(_))
 
 
 
 open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022lts',
  'w').write(str(_))
 
 
 
 
  'org_babel_python_eoe'
 
  'org_babel_python_eoe'
 
  'org_babel_python_eoe'
 
 
 
 
 
 



Re: [O] python :session does return

2014-01-15 Thread Eric Schulte
I think the issue here is that python users seem less likely (per user
on average) to edit the related Org-mode support (i.e., ob-python.el)
than users of some other languages which may be less popular in the
large but have better Org-mode support.

Also, as a maintainer of Org-mode's code block support, I personally do
not use Python.

Best,

Ken Mankoff mank...@gmail.com writes:

 Hi John,

 Yes, you and others in that thread seem to be experiencing the same
 problem, although there are also different issues discussed there.

 I'm a bit surprised... With the popularity of python I would expect more
 org users to have run into this and it to be fixed, but perhaps it isn't as
 widely used as I thought. Anyway, it is now usable even if the 'print'
 statements don't show up.

   -k.



 On Tue, Jan 14, 2014 at 6:04 PM, John Hendy jw.he...@gmail.com wrote:

 On Tue, Jan 14, 2014 at 7:38 AM, Ken Mankoff mank...@gmail.com 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.
 

 This sounded familiar to me, so I googled around for Org mailing list
 discussions I was involved in related to python. Does this shed any
 new light?
 - https://www.mail-archive.com/emacs-orgmode@gnu.org/msg68542.html

 Seems that the discussion ended with the possibility that it was an
 emacs change to python.el, and not related to Org, but I'm not sure if
 any actions were ever taken regarding that. In any case, the
 discussion features a discrepancy between python behavior with
 `:session name` and without, so it seemed like a possible candidate to
 pass along!



 Best regards,
 John

  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.
 
  If I look at the *transect* buffer, I see the following. The code runs
 just
  fine, but for some reason it does not return.
 
-k.
 
 
 
  Enthought Canopy Python 2.7.3 | 64-bit | (default, Dec  2 2013, 16:19:29)
  [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
  Type help, copyright, credits or license for more information.
  import numpy as np
  Start .pythonrc
  End .pythonrc
 
  import numpy as np
 
  x = np.arange(12)
  x = np.arange(12)
 
 
 
 open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022Yjm',
  'w').write(str(_))
 
 open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022Yjm',
  'w').write(str(_))
 
 
 
 
  'org_babel_python_eoe'
  'org_babel_python_eoe'
 
   Traceback (most recent call last):
 
File stdin, line 1, in module
  NameError: name '_' is not defined
 
'org_babel_python_eoe'
  import numpy as np
 
  import numpy as np
  x = np.arange(12)
 
  x = np.arange(12)
 
 
 
 
 open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022lts',
  'w').write(str(_))
 
 
 
 open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022lts',
  'w').write(str(_))
 
 
 
 
  'org_babel_python_eoe'
 
  'org_babel_python_eoe'
 
  'org_babel_python_eoe'
 
 
 
 
 
 


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



Re: [O] python :session does return

2014-01-15 Thread John Hendy
On Wed, Jan 15, 2014 at 6:22 AM, Ken Mankoff mank...@gmail.com wrote:
 Hi John,

 Yes, you and others in that thread seem to be experiencing the same problem,
 although there are also different issues discussed there.

 I'm a bit surprised... With the popularity of python I would expect more org
 users to have run into this and it to be fixed, but perhaps it isn't as
 widely used as I thought. Anyway, it is now usable even if the 'print'
 statements don't show up.

Sorry I haven't been following along quite as closely as I probably
should have... I booted into Linux to remove the issue of setting up
python on my Windows partition. Are my results contrary to what's been
happening to you?


#+begin_src ~/Desktop/test.org

* heading

Using =:results output=

#+BEGIN_SRC python :results output :session transect
import numpy as np
x = np.arange(12)
print x
#+END_SRC

#+RESULTS:
:
:  [ 0  1  2  3  4  5  6  7  8  9 10 11]

#+end_src

#+begin_src ~/Desktop/test.org

* heading

I can also use =:results value= and it spits out an org table

#+BEGIN_SRC python :results value :session transect
import numpy as np
x = np.arange(12)
x
#+END_SRC

#+RESULTS:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |

#+end_src

#+begin_src Emacs *transect* buffer

 import numpy as np
 x = np.arange(12)
 print x
[ 0  1  2  3  4  5  6  7  8  9 10 11]



 'org_babel_python_eoe'
'org_babel_python_eoe'


#+end_src

#+begin_src .emacs

;; Arch linux installs python3 by default, and python is bound to it
;; need to set this variable to make sure we're using python v2
(setq org-babel-python-command python2)

#+end_src

$ python2 --version
Python 2.7.6

M-x org-version
Org-mode version 8.2.3c (release_8.2.3c-227-g54a64f @
/home/jwhendy/.elisp/org.git/lisp/)

$ emacs --version
GNU Emacs 24.3.1

I think the :session name - a *name* session is still a bit goofy,
but I at the very least I wanted to share that I don't get any hanging
behavior and seem to get coherent results out of a python babel code
block.


Best regards,
John


   -k.



 On Tue, Jan 14, 2014 at 6:04 PM, John Hendy jw.he...@gmail.com wrote:

 On Tue, Jan 14, 2014 at 7:38 AM, Ken Mankoff mank...@gmail.com 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.
 

 This sounded familiar to me, so I googled around for Org mailing list
 discussions I was involved in related to python. Does this shed any
 new light?
 - https://www.mail-archive.com/emacs-orgmode@gnu.org/msg68542.html

 Seems that the discussion ended with the possibility that it was an
 emacs change to python.el, and not related to Org, but I'm not sure if
 any actions were ever taken regarding that. In any case, the
 discussion features a discrepancy between python behavior with
 `:session name` and without, so it seemed like a possible candidate to
 pass along!



 Best regards,
 John

  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.
 
  If I look at the *transect* buffer, I see the following. The code runs
  just
  fine, but for some reason it does not return.
 
-k.
 
 
 
  Enthought Canopy Python 2.7.3 | 64-bit | (default, Dec  2 2013,
  16:19:29)
  [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
  Type help, copyright, credits or license for more information.
  import numpy as np
  Start .pythonrc
  End .pythonrc
 
  import numpy as np
 
  x = np.arange(12)
  x = np.arange(12)
 
 
 
  open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022Yjm',
  'w').write(str(_))
 
  open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022Yjm',
  'w').write(str(_))
 
 
 
 
  'org_babel_python_eoe'
  'org_babel_python_eoe'
 
   Traceback (most recent call last):
 
File stdin, line 1, in module
  NameError: name '_' is not defined
 
'org_babel_python_eoe'
  import numpy as np
 
  import numpy as np
  x = np.arange(12)
 
  x = np.arange(12)
 
 
 
 
  open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022lts',
  'w').write(str(_))
 
 
 
  open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022lts',
  'w').write(str(_))
 
 
 
 
  'org_babel_python_eoe'
 
  'org_babel_python_eoe'
 
  'org_babel_python_eoe'
 
 
 
 
 
 





[O] python :session does return

2014-01-14 Thread Ken Mankoff


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.


If I look at the *transect* buffer, I see the following. The code 
runs just fine, but for some reason it does not return.


  -k.



Enthought Canopy Python 2.7.3 | 64-bit | (default, Dec  2 2013, 
16:19:29)

[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type help, copyright, credits or license for more 
information.

import numpy as np
Start .pythonrc
End .pythonrc

import numpy as np

x = np.arange(12)
x = np.arange(12)


open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022Yjm', 
'w').write(str(_))
open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022Yjm', 
'w').write(str(_))





'org_babel_python_eoe'
'org_babel_python_eoe'

 Traceback (most recent call last):

  File stdin, line 1, in module
NameError: name '_' is not defined

  'org_babel_python_eoe'
import numpy as np

import numpy as np
x = np.arange(12)

x = np.arange(12)




open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022lts', 
'w').write(str(_))


open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022lts', 
'w').write(str(_))









'org_babel_python_eoe'

'org_babel_python_eoe'

'org_babel_python_eoe'









Re: [O] python :session does return

2014-01-14 Thread Ken Mankoff

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_wrcgn/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_wrcgn/T/babel-35562TZV/python-3$
In [15]: 'org_babel_python_eoe'
In [15]: Out[15]: 'org_babel_python_eoe'



Re: [O] python :session does return

2014-01-14 Thread Nick Dokos
Ken Mankoff mank...@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 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_wrcgn/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_wrcgn/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.

Nick




Re: [O] python :session does return

2014-01-14 Thread Ken Mankoff
On Tue, Jan 14, 2014 at 11:32 AM, Nick Dokos ndo...@gmail.com wrote:

 Ken Mankoff mank...@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 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_wrcgn/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_wrcgn/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.


Re: [O] python :session does return

2014-01-14 Thread Nick Dokos
Ken Mankoff mank...@gmail.com writes:

 On Tue, Jan 14, 2014 at 11:32 AM, Nick Dokos ndo...@gmail.com wrote:

 Ken Mankoff mank...@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 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_wrcgn/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_wrcgn/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





Re: [O] python :session does return

2014-01-14 Thread Ken Mankoff

On Tue, 14 Jan 2014, Nick Dokos wrote:


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.




Yes I got your comment. The :results output doesn't work either.

  -k.



Re: [O] python :session does return

2014-01-14 Thread John Hendy
On Tue, Jan 14, 2014 at 7:38 AM, Ken Mankoff mank...@gmail.com 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.


This sounded familiar to me, so I googled around for Org mailing list
discussions I was involved in related to python. Does this shed any
new light?
- https://www.mail-archive.com/emacs-orgmode@gnu.org/msg68542.html

Seems that the discussion ended with the possibility that it was an
emacs change to python.el, and not related to Org, but I'm not sure if
any actions were ever taken regarding that. In any case, the
discussion features a discrepancy between python behavior with
`:session name` and without, so it seemed like a possible candidate to
pass along!



Best regards,
John

 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.

 If I look at the *transect* buffer, I see the following. The code runs just
 fine, but for some reason it does not return.

   -k.



 Enthought Canopy Python 2.7.3 | 64-bit | (default, Dec  2 2013, 16:19:29)
 [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
 Type help, copyright, credits or license for more information.
 import numpy as np
 Start .pythonrc
 End .pythonrc

 import numpy as np

 x = np.arange(12)
 x = np.arange(12)


 open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022Yjm',
 'w').write(str(_))
 open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022Yjm',
 'w').write(str(_))




 'org_babel_python_eoe'
 'org_babel_python_eoe'

  Traceback (most recent call last):

   File stdin, line 1, in module
 NameError: name '_' is not defined

   'org_babel_python_eoe'
 import numpy as np

 import numpy as np
 x = np.arange(12)

 x = np.arange(12)



 open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022lts',
 'w').write(str(_))


 open('/var/folders/60/jb7kfrsn2jd90hpcgj4m_wrcgn/T/babel-28022EFF/python-28022lts',
 'w').write(str(_))




 'org_babel_python_eoe'

 'org_babel_python_eoe'

 'org_babel_python_eoe'