emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* babel python example not reproducible
@ 2014-06-11  5:11 Shiyuan
  2014-06-11  7:48 ` Doyley, Marvin
  0 siblings, 1 reply; 14+ messages in thread
From: Shiyuan @ 2014-06-11  5:11 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 662 bytes --]

Hi,
     I try to understand the difference of "session" and "non-session" as
in
 http://orgmode.org/manual/Results-of-evaluation.html#Results-of-evaluation
<http://orgmode.org/manual/Results-of-evaluation.html#Results-of-evaluation>

However, I copy-paste the example but have different result. It looks like
that the result contains whatever sent to the interactive shell too. Any
option I need to set to reproduce the same result as in the manual?  I am
using python 2.7.5 + emacs 24.3.9 + orgmode 8.2.6.

#+BEGIN_SRC python :results output :session
 print "hello"
 2
 print "bye"
#+END_SRC

#+RESULTS:
: print "hello"
: hello
: 2
: 2
: print "bye"
: bye
:
:

[-- Attachment #2: Type: text/html, Size: 1006 bytes --]

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

* Re: babel python example not reproducible
  2014-06-11  5:11 babel python example not reproducible Shiyuan
@ 2014-06-11  7:48 ` Doyley, Marvin
  2014-06-16  5:59   ` Shiyuan
  0 siblings, 1 reply; 14+ messages in thread
From: Doyley, Marvin @ 2014-06-11  7:48 UTC (permalink / raw)
  To: emacs-orgmode

Works for me, see example below
#+BEGIN_SRC python :results output :session foo

x=100
print "hello"
2
print "bye"
#+END_SRC

#+RESULTS:
: 
: >>> hello
: 2
: bye

#+BEGIN_SRC python :results output :session foo

print "hello good bye"
print "Printing value from previous session", x
#+END_SRC

#+RESULTS:
: 
: hello good bye
: Printing value from previous session 100

The only difference is that I like to give my session a name and for
what it is worth I am using ipython (don't think this will make a difference). You can do this including the
following statement in your .emacs file

(setq python-shell-interpreter "ipython")
(setq python-shell-interpreter-args "--pylab")

Hope this help.
Cheers,
M

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

* Re: babel python example not reproducible
  2014-06-11  7:48 ` Doyley, Marvin
@ 2014-06-16  5:59   ` Shiyuan
  2014-06-16 12:19     ` Nick Dokos
  2014-06-16 14:35     ` Doyley, Marvin
  0 siblings, 2 replies; 14+ messages in thread
From: Shiyuan @ 2014-06-16  5:59 UTC (permalink / raw)
  To: Doyley, Marvin; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1509 bytes --]

The two setting doesn't seem to have effect.
(setq python-shell-interpreter "ipython")
(setq python-shell-interpreter-args "--pylab")
When I did `C-c C-c` on the SRC block to execute the code, emacs created a
buffer with the interior python process. When I switched to the process, I
saw it is python 2.5.3, not ipython.

Also, it looks like the problem is with the shell interpreter. If I enter
command directly in the shell buffer, the shell buffer will echo command
itself and then the result.

>>> print "Hello"
print "Hello"
Hello.

Is there any setting to control this shell behavior? Can I make the python
shell not echo the command? Thanks.


On Wed, Jun 11, 2014 at 12:48 AM, Doyley, Marvin <mdoyley@ur.rochester.edu>
wrote:

> Works for me, see example below
> #+BEGIN_SRC python :results output :session foo
>
> x=100
> print "hello"
> 2
> print "bye"
> #+END_SRC
>
> #+RESULTS:
> :
> : >>> hello
> : 2
> : bye
>
> #+BEGIN_SRC python :results output :session foo
>
> print "hello good bye"
> print "Printing value from previous session", x
> #+END_SRC
>
> #+RESULTS:
> :
> : hello good bye
> : Printing value from previous session 100
>
> The only difference is that I like to give my session a name and for
> what it is worth I am using ipython (don't think this will make a
> difference). You can do this including the
> following statement in your .emacs file
>
> (setq python-shell-interpreter "ipython")
> (setq python-shell-interpreter-args "--pylab")
>
> Hope this help.
> Cheers,
> M
>
>
>

[-- Attachment #2: Type: text/html, Size: 2454 bytes --]

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

* Re: babel python example not reproducible
  2014-06-16  5:59   ` Shiyuan
@ 2014-06-16 12:19     ` Nick Dokos
  2014-06-16 14:35     ` Doyley, Marvin
  1 sibling, 0 replies; 14+ messages in thread
From: Nick Dokos @ 2014-06-16 12:19 UTC (permalink / raw)
  To: emacs-orgmode

Shiyuan <gshy2014@gmail.com> writes:

> The two setting doesn't seem to have effect.  
> (setq python-shell-interpreter "ipython")
> (setq python-shell-interpreter-args "--pylab")
>
> When I did `C-c C-c` on the SRC block to execute the code, emacs
> created a buffer with the interior python process. When I switched to
> the process, I saw it is python 2.5.3, not ipython.  
>
> Also, it looks like the problem is with the shell interpreter. If I
> enter command directly in the shell buffer, the shell buffer will echo
> command itself and then the result. 
>
>>>> print "Hello"
> print "Hello"
> Hello. 
>
> Is there any setting to control this shell behavior? Can I make the
> python shell not echo the command? Thanks.  
>

When a *shell* does that to me, I do (on Linux)

$ stty -echo

but I'm not sure where that would fit into your setup.

Nick

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

* Re: babel python example not reproducible
  2014-06-16  5:59   ` Shiyuan
  2014-06-16 12:19     ` Nick Dokos
@ 2014-06-16 14:35     ` Doyley, Marvin
  2014-06-16 15:03       ` Eric Schulte
  1 sibling, 1 reply; 14+ messages in thread
From: Doyley, Marvin @ 2014-06-16 14:35 UTC (permalink / raw)
  To: emacs-orgmode


Hi Shiyuan,

I think the problem is that Emacs or babel is using python located in
/usr/bin or /usr/local/sbin  rather than default python or ipython. The way I got
around this is rename python in these locations to python_old and then did
a soft link to ipython (i.e., ln -s /anaconda/bin/ipython python). 

I am sure there is a smarter way of telling babel to use ipython, but
this was my work around.

Hope this help
cheers,
M

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

* Re: babel python example not reproducible
  2014-06-16 14:35     ` Doyley, Marvin
@ 2014-06-16 15:03       ` Eric Schulte
  2014-06-16 16:12         ` Doyley, Marvin
  0 siblings, 1 reply; 14+ messages in thread
From: Eric Schulte @ 2014-06-16 15:03 UTC (permalink / raw)
  To: Doyley, Marvin; +Cc: emacs-orgmode

mdoyley@ur.rochester.edu (Doyley, Marvin) writes:

> Hi Shiyuan,
>
> I think the problem is that Emacs or babel is using python located in
> /usr/bin or /usr/local/sbin  rather than default python or ipython. The way I got
> around this is rename python in these locations to python_old and then did
> a soft link to ipython (i.e., ln -s /anaconda/bin/ipython python). 
>
> I am sure there is a smarter way of telling babel to use ipython, but
> this was my work around.
>

See the `org-babel-python-command' variable.

>
> Hope this help
> cheers,
> M
>
>
>
>

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)

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

* Re: babel python example not reproducible
  2014-06-16 15:03       ` Eric Schulte
@ 2014-06-16 16:12         ` Doyley, Marvin
  2014-06-17  6:21           ` Shiyuan
  0 siblings, 1 reply; 14+ messages in thread
From: Doyley, Marvin @ 2014-06-16 16:12 UTC (permalink / raw)
  To: emacs-orgmode

Hi Eric,

Thanks for showing me the smart way of doing this.

cheers,
M
-- 

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

* Re: babel python example not reproducible
  2014-06-16 16:12         ` Doyley, Marvin
@ 2014-06-17  6:21           ` Shiyuan
  2014-06-17 11:54             ` Andreas Röhler
  2014-06-18 13:59             ` Eric Schulte
  0 siblings, 2 replies; 14+ messages in thread
From: Shiyuan @ 2014-06-17  6:21 UTC (permalink / raw)
  To: Doyley, Marvin; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2122 bytes --]

Hi all,
      I found a solution to fix the echo problem of the emacs python shell:
http://stackoverflow.com/questions/8060609/python-interpreter-in-emacs-repeats-lines

That is, in the Interior Python buffer, do
M-: (setq comint-process-echoes t) ;; or nil

Now, if I enter command directly in the interior python buffer, the command
is not echoed and this is what I want.

However, When I evaluate the python src code block in org-mode(by `C-c
C-c`), the problem persists. I notice every time I evaluate the block, I
see 'org_babel_python_eoe' in the interior python buffer.

I  stumbled on a very strange emacs behavior. When I fiddled around, at
some point, I produced the correct answer as the manual. I thought I got
the right setup, but when I saved everything and restarted emacs, problem
persists. Will it be a sign of anything wrong?

What's even stranger is that: the evaluation for the first time gives
different results from the evaluation for the second time,  on exactly the
same src_block:

This is what I got when I evaluation the code block for the first time:
-------------------------------------
#+BEGIN_SRC python :results output :session foo
x=100
print "hello"
2
print "bye"
#+END_SRC

#+RESULTS:
#+begin_example

x=100
>>> print "hello"
>>> hello
2
2
print "bye"
bye


#+end_example
-----------------------------------------------
-------------------------------------------------------

The following is what I got when I evaluate the same block again:
#+BEGIN_SRC python :results output :session foo
x=100
print "hello"
2
print "bye"
#+END_SRC

#+RESULTS:
: x=100
: print "hello"
: hello
: 2
: 2
: print "bye"
: bye
:
:

Notice that the prompt symbol ">>>" is in the result for the first
evaluation but not in the second evaluation.  Also the result is not
embedded in the #+being_example/#+end_example for the second evaluation.

I want to hunt down the problem. Any hints/helps is greatly appreciated.

Shiyuan




On Mon, Jun 16, 2014 at 9:12 AM, Doyley, Marvin <mdoyley@ur.rochester.edu>
wrote:

> Hi Eric,
>
> Thanks for showing me the smart way of doing this.
>
> cheers,
> M
> --
>
>
>
>

[-- Attachment #2: Type: text/html, Size: 9134 bytes --]

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

* Re: babel python example not reproducible
  2014-06-17  6:21           ` Shiyuan
@ 2014-06-17 11:54             ` Andreas Röhler
  2014-06-18 14:02               ` Eric Schulte
  2014-06-18 13:59             ` Eric Schulte
  1 sibling, 1 reply; 14+ messages in thread
From: Andreas Röhler @ 2014-06-17 11:54 UTC (permalink / raw)
  To: emacs-orgmode

On 17.06.2014 08:21, Shiyuan wrote:
> Hi all,
>        I found a solution to fix the echo problem of the emacs python shell:
> http://stackoverflow.com/questions/8060609/python-interpreter-in-emacs-repeats-lines
>
> That is, in the Interior Python buffer, do
> M-: (setq comint-process-echoes t) ;; or nil
>
> Now, if I enter command directly in the interior python buffer, the command
> is not echoed and this is what I want.
>
> However, When I evaluate the python src code block in org-mode(by `C-c
> C-c`), the problem persists. I notice every time I evaluate the block, I
> see 'org_babel_python_eoe' in the interior python buffer.
>
> I  stumbled on a very strange emacs behavior. When I fiddled around, at
> some point, I produced the correct answer as the manual. I thought I got
> the right setup, but when I saved everything and restarted emacs, problem
> persists. Will it be a sign of anything wrong?
>
> What's even stranger is that: the evaluation for the first time gives
> different results from the evaluation for the second time,  on exactly the
> same src_block:
>
> This is what I got when I evaluation the code block for the first time:
> -------------------------------------
> #+BEGIN_SRC python :results output :session foo
> x=100
> print "hello"
> 2
> print "bye"
> #+END_SRC
>
> #+RESULTS:
> #+begin_example
>
> x=100
>>>> print "hello"
>>>> hello
> 2
> 2
> print "bye"
> bye
>
>
> #+end_example
> -----------------------------------------------
> -------------------------------------------------------
>
> The following is what I got when I evaluate the same block again:
> #+BEGIN_SRC python :results output :session foo
> x=100
> print "hello"
> 2
> print "bye"
> #+END_SRC
>
> #+RESULTS:
> : x=100
> : print "hello"
> : hello
> : 2
> : 2
> : print "bye"
> : bye
> :
> :
>
> Notice that the prompt symbol ">>>" is in the result for the first
> evaluation but not in the second evaluation.  Also the result is not
> embedded in the #+being_example/#+end_example for the second evaluation.
>
> I want to hunt down the problem. Any hints/helps is greatly appreciated.
>
> Shiyuan
>
>

Hi Guys,

please permit a comment after some times - it's just not to create heroes :)

IMHO the complexity orb-babel took by creating its own slots for symbols like function names, variables etc.
is not to handle reliably across the languages.

A net and simple way out would be just to employ commands delivered by existing Emacs modes on org-source sections.
Inserting the results might be provided by a hook.

Cheers,

Andreas

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

* Re: babel python example not reproducible
  2014-06-17  6:21           ` Shiyuan
  2014-06-17 11:54             ` Andreas Röhler
@ 2014-06-18 13:59             ` Eric Schulte
  2014-06-19  5:57               ` Andreas Röhler
  1 sibling, 1 reply; 14+ messages in thread
From: Eric Schulte @ 2014-06-18 13:59 UTC (permalink / raw)
  To: Shiyuan; +Cc: emacs-orgmode, Doyley, Marvin

Shiyuan <gshy2014@gmail.com> writes:

> Hi all,
>       I found a solution to fix the echo problem of the emacs python shell:
> http://stackoverflow.com/questions/8060609/python-interpreter-in-emacs-repeats-lines
>
> That is, in the Interior Python buffer, do
> M-: (setq comint-process-echoes t) ;; or nil
>
> Now, if I enter command directly in the interior python buffer, the command
> is not echoed and this is what I want.
>
> However, When I evaluate the python src code block in org-mode(by `C-c
> C-c`), the problem persists. I notice every time I evaluate the block, I
> see 'org_babel_python_eoe' in the interior python buffer.
>
> I  stumbled on a very strange emacs behavior. When I fiddled around, at
> some point, I produced the correct answer as the manual. I thought I got
> the right setup, but when I saved everything and restarted emacs, problem
> persists. Will it be a sign of anything wrong?
>
> What's even stranger is that: the evaluation for the first time gives
> different results from the evaluation for the second time,  on exactly the
> same src_block:
>
> This is what I got when I evaluation the code block for the first time:
> -------------------------------------
> #+BEGIN_SRC python :results output :session foo
> x=100
> print "hello"
> 2
> print "bye"
> #+END_SRC
>
> #+RESULTS:
> #+begin_example
>
> x=100
>>>> print "hello"
>>>> hello
> 2
> 2
> print "bye"
> bye
>
>
> #+end_example
> -----------------------------------------------
> -------------------------------------------------------
>
> The following is what I got when I evaluate the same block again:
> #+BEGIN_SRC python :results output :session foo
> x=100
> print "hello"
> 2
> print "bye"
> #+END_SRC
>
> #+RESULTS:
> : x=100
> : print "hello"
> : hello
> : 2
> : 2
> : print "bye"
> : bye
> :
> :
>
> Notice that the prompt symbol ">>>" is in the result for the first
> evaluation but not in the second evaluation.

This issue has been raised before, it is a quirk of how the python
session starts up.  I think we've done what we can to handle this on the
Org-mode side, I'd ask for a fix on the python.el maintainers.

> Also the result is not embedded in the #+being_example/#+end_example
> for the second evaluation.
>

Yes, short examples are examplized with ":" instead of the heavier
weight example blocks.  The results are functionally equivalent, but you
can customize the size at which different methods are used by changing
the `org-babel-min-lines-for-block-output' variable.

>
> I want to hunt down the problem. Any hints/helps is greatly appreciated.
>

Hope this helps.  Sadly Emacs python support is sub-par and as a
consumer, Org-mode python code blocks suffer.

Best,

>
> Shiyuan
>
>
>
>
> On Mon, Jun 16, 2014 at 9:12 AM, Doyley, Marvin <mdoyley@ur.rochester.edu>
> wrote:
>
>> Hi Eric,
>>
>> Thanks for showing me the smart way of doing this.
>>
>> cheers,
>> M
>> --
>>
>>
>>
>>

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)

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

* Re: babel python example not reproducible
  2014-06-17 11:54             ` Andreas Röhler
@ 2014-06-18 14:02               ` Eric Schulte
  0 siblings, 0 replies; 14+ messages in thread
From: Eric Schulte @ 2014-06-18 14:02 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: emacs-orgmode

> Hi Guys,
>
> please permit a comment after some times - it's just not to create
> heroes :)
>
> IMHO the complexity orb-babel took by creating its own slots for
> symbols like function names, variables etc.  is not to handle reliably
> across the languages.
>

I don't understand what you mean by the above.

>
> A net and simple way out would be just to employ commands delivered by
> existing Emacs modes on org-source sections.  Inserting the results
> might be provided by a hook.
>

This is what Org-mode does when possible, and this is why some language
modes are both much simpler and much more reliable than others, e.g.,
because of Emacs' excellent support for common lisp ob-lisp.el is both
shorter and provides higher quality support than ob-python.el.

$ wc -l lisp/ob-{lisp,python}.el
  111 lisp/ob-lisp.el
  346 lisp/ob-python.el

If I've miss-understood the above please clarify.

Thanks,
Eric

>
> Cheers,
>
> Andreas
>
>
>
>
>

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)

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

* Re: babel python example not reproducible
  2014-06-18 13:59             ` Eric Schulte
@ 2014-06-19  5:57               ` Andreas Röhler
  2014-06-19 13:40                 ` Eric Schulte
  0 siblings, 1 reply; 14+ messages in thread
From: Andreas Röhler @ 2014-06-19  5:57 UTC (permalink / raw)
  To: emacs-orgmode, Eric Schulte

On 18.06.2014 15:59, Eric Schulte wrote:
> Shiyuan <gshy2014@gmail.com> writes:
>
>> Hi all,
>>        I found a solution to fix the echo problem of the emacs python shell:
>> http://stackoverflow.com/questions/8060609/python-interpreter-in-emacs-repeats-lines
>>
>> That is, in the Interior Python buffer, do
>> M-: (setq comint-process-echoes t) ;; or nil
>>
>> Now, if I enter command directly in the interior python buffer, the command
>> is not echoed and this is what I want.
>>
>> However, When I evaluate the python src code block in org-mode(by `C-c
>> C-c`), the problem persists. I notice every time I evaluate the block, I
>> see 'org_babel_python_eoe' in the interior python buffer.
>>
>> I  stumbled on a very strange emacs behavior. When I fiddled around, at
>> some point, I produced the correct answer as the manual. I thought I got
>> the right setup, but when I saved everything and restarted emacs, problem
>> persists. Will it be a sign of anything wrong?
>>
>> What's even stranger is that: the evaluation for the first time gives
>> different results from the evaluation for the second time,  on exactly the
>> same src_block:
>>
>> This is what I got when I evaluation the code block for the first time:
>> -------------------------------------
>> #+BEGIN_SRC python :results output :session foo
>> x=100
>> print "hello"
>> 2
>> print "bye"
>> #+END_SRC
>>
>> #+RESULTS:
>> #+begin_example
>>
>> x=100
>>>>> print "hello"
>>>>> hello
>> 2
>> 2
>> print "bye"
>> bye
>>
>>
>> #+end_example
>> -----------------------------------------------
>> -------------------------------------------------------
>>
>> The following is what I got when I evaluate the same block again:
>> #+BEGIN_SRC python :results output :session foo
>> x=100
>> print "hello"
>> 2
>> print "bye"
>> #+END_SRC
>>
>> #+RESULTS:
>> : x=100
>> : print "hello"
>> : hello
>> : 2
>> : 2
>> : print "bye"
>> : bye
>> :
>> :
>>
>> Notice that the prompt symbol ">>>" is in the result for the first
>> evaluation but not in the second evaluation.
>
> This issue has been raised before, it is a quirk of how the python
> session starts up.  I think we've done what we can to handle this on the
> Org-mode side, I'd ask for a fix on the python.el maintainers.


The prompts appear as respond from Python-process when setup-code is sent at the beginning.
org-babel already knows how to fetch only the results from last prompt.
Probably separating a first run-python/py-shell from execute-process would do it.

Best,

Andreas

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

* Re: babel python example not reproducible
  2014-06-19  5:57               ` Andreas Röhler
@ 2014-06-19 13:40                 ` Eric Schulte
  2014-06-20  5:53                   ` Andreas Röhler
  0 siblings, 1 reply; 14+ messages in thread
From: Eric Schulte @ 2014-06-19 13:40 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: emacs-orgmode, Eric Schulte

Andreas Röhler <andreas.roehler@easy-emacs.de> writes:

> On 18.06.2014 15:59, Eric Schulte wrote:
>> Shiyuan <gshy2014@gmail.com> writes:
>>
>>> Hi all,
>>>        I found a solution to fix the echo problem of the emacs python shell:
>>> http://stackoverflow.com/questions/8060609/python-interpreter-in-emacs-repeats-lines
>>>
>>> That is, in the Interior Python buffer, do
>>> M-: (setq comint-process-echoes t) ;; or nil
>>>
>>> Now, if I enter command directly in the interior python buffer, the command
>>> is not echoed and this is what I want.
>>>
>>> However, When I evaluate the python src code block in org-mode(by `C-c
>>> C-c`), the problem persists. I notice every time I evaluate the block, I
>>> see 'org_babel_python_eoe' in the interior python buffer.
>>>
>>> I  stumbled on a very strange emacs behavior. When I fiddled around, at
>>> some point, I produced the correct answer as the manual. I thought I got
>>> the right setup, but when I saved everything and restarted emacs, problem
>>> persists. Will it be a sign of anything wrong?
>>>
>>> What's even stranger is that: the evaluation for the first time gives
>>> different results from the evaluation for the second time,  on exactly the
>>> same src_block:
>>>
>>> This is what I got when I evaluation the code block for the first time:
>>> -------------------------------------
>>> #+BEGIN_SRC python :results output :session foo
>>> x=100
>>> print "hello"
>>> 2
>>> print "bye"
>>> #+END_SRC
>>>
>>> #+RESULTS:
>>> #+begin_example
>>>
>>> x=100
>>>>>> print "hello"
>>>>>> hello
>>> 2
>>> 2
>>> print "bye"
>>> bye
>>>
>>>
>>> #+end_example
>>> -----------------------------------------------
>>> -------------------------------------------------------
>>>
>>> The following is what I got when I evaluate the same block again:
>>> #+BEGIN_SRC python :results output :session foo
>>> x=100
>>> print "hello"
>>> 2
>>> print "bye"
>>> #+END_SRC
>>>
>>> #+RESULTS:
>>> : x=100
>>> : print "hello"
>>> : hello
>>> : 2
>>> : 2
>>> : print "bye"
>>> : bye
>>> :
>>> :
>>>
>>> Notice that the prompt symbol ">>>" is in the result for the first
>>> evaluation but not in the second evaluation.
>>
>> This issue has been raised before, it is a quirk of how the python
>> session starts up.  I think we've done what we can to handle this on the
>> Org-mode side, I'd ask for a fix on the python.el maintainers.
>
>
> The prompts appear as respond from Python-process when setup-code is sent at the beginning.
> org-babel already knows how to fetch only the results from last prompt.
> Probably separating a first run-python/py-shell from execute-process would do it.
>

I don't follow the above with sufficient clarity to implement your
suggestion.  Could you provide a patch to the
`org-babel-python-initiate-session-by-key' function?

Thanks,
Eric

>
> Best,
>
> Andreas

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)

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

* Re: babel python example not reproducible
  2014-06-19 13:40                 ` Eric Schulte
@ 2014-06-20  5:53                   ` Andreas Röhler
  0 siblings, 0 replies; 14+ messages in thread
From: Andreas Röhler @ 2014-06-20  5:53 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

On 19.06.2014 15:40, Eric Schulte wrote:
> Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
>
>> On 18.06.2014 15:59, Eric Schulte wrote:
>>> Shiyuan <gshy2014@gmail.com> writes:
>>>
>>>> Hi all,
>>>>         I found a solution to fix the echo problem of the emacs python shell:
>>>> http://stackoverflow.com/questions/8060609/python-interpreter-in-emacs-repeats-lines
>>>>
>>>> That is, in the Interior Python buffer, do
>>>> M-: (setq comint-process-echoes t) ;; or nil
>>>>
>>>> Now, if I enter command directly in the interior python buffer, the command
>>>> is not echoed and this is what I want.
>>>>
>>>> However, When I evaluate the python src code block in org-mode(by `C-c
>>>> C-c`), the problem persists. I notice every time I evaluate the block, I
>>>> see 'org_babel_python_eoe' in the interior python buffer.
>>>>
>>>> I  stumbled on a very strange emacs behavior. When I fiddled around, at
>>>> some point, I produced the correct answer as the manual. I thought I got
>>>> the right setup, but when I saved everything and restarted emacs, problem
>>>> persists. Will it be a sign of anything wrong?
>>>>
>>>> What's even stranger is that: the evaluation for the first time gives
>>>> different results from the evaluation for the second time,  on exactly the
>>>> same src_block:
>>>>
>>>> This is what I got when I evaluation the code block for the first time:
>>>> -------------------------------------
>>>> #+BEGIN_SRC python :results output :session foo
>>>> x=100
>>>> print "hello"
>>>> 2
>>>> print "bye"
>>>> #+END_SRC
>>>>
>>>> #+RESULTS:
>>>> #+begin_example
>>>>
>>>> x=100
>>>>>>> print "hello"
>>>>>>> hello
>>>> 2
>>>> 2
>>>> print "bye"
>>>> bye
>>>>
>>>>
>>>> #+end_example
>>>> -----------------------------------------------
>>>> -------------------------------------------------------
>>>>
>>>> The following is what I got when I evaluate the same block again:
>>>> #+BEGIN_SRC python :results output :session foo
>>>> x=100
>>>> print "hello"
>>>> 2
>>>> print "bye"
>>>> #+END_SRC
>>>>
>>>> #+RESULTS:
>>>> : x=100
>>>> : print "hello"
>>>> : hello
>>>> : 2
>>>> : 2
>>>> : print "bye"
>>>> : bye
>>>> :
>>>> :
>>>>
>>>> Notice that the prompt symbol ">>>" is in the result for the first
>>>> evaluation but not in the second evaluation.
>>>
>>> This issue has been raised before, it is a quirk of how the python
>>> session starts up.  I think we've done what we can to handle this on the
>>> Org-mode side, I'd ask for a fix on the python.el maintainers.
>>
>>
>> The prompts appear as respond from Python-process when setup-code is sent at the beginning.
>> org-babel already knows how to fetch only the results from last prompt.
>> Probably separating a first run-python/py-shell from execute-process would do it.
>>
>
> I don't follow the above with sufficient clarity to implement your
> suggestion.  Could you provide a patch to the
> `org-babel-python-initiate-session-by-key' function?
>

Hi Eric,

was asked off-list not to send patches...

Sorry,

Andreas

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

end of thread, other threads:[~2014-06-20  5:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-11  5:11 babel python example not reproducible Shiyuan
2014-06-11  7:48 ` Doyley, Marvin
2014-06-16  5:59   ` Shiyuan
2014-06-16 12:19     ` Nick Dokos
2014-06-16 14:35     ` Doyley, Marvin
2014-06-16 15:03       ` Eric Schulte
2014-06-16 16:12         ` Doyley, Marvin
2014-06-17  6:21           ` Shiyuan
2014-06-17 11:54             ` Andreas Röhler
2014-06-18 14:02               ` Eric Schulte
2014-06-18 13:59             ` Eric Schulte
2014-06-19  5:57               ` Andreas Röhler
2014-06-19 13:40                 ` Eric Schulte
2014-06-20  5:53                   ` Andreas Röhler

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).