emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-babel python eval discrepancy
@ 2017-08-03 17:31 Dushyant Juneja
  2017-08-03 18:22 ` Dov Grobgeld
  2017-08-03 18:31 ` Adam Porter
  0 siblings, 2 replies; 4+ messages in thread
From: Dushyant Juneja @ 2017-08-03 17:31 UTC (permalink / raw)
  To: emacs-org list

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

Hi,

I have the following code block in my org mode based literate programming
notes:

#+BEGIN_SRC python
print('1+2 > 4 is ', 1+2 > 4)
print("What is 3 + 2?", 3 + 2)
#+END_SRC

When I tangle it and run the script, it gives me expected output as follows:

> python notes.py
1+2 > 4 is  False
What is 3 + 2? 5

However, in buffer evaluation (using =C-c C-c= with cursor on src block)
gives me the following output, which seems unexpected:

#+BEGIN_SRC python
print('1+2 > 4 is ', 1+2 > 4)
print("What is 3 + 2?", 3 + 2)
#+END_SRC

#+RESULTS:
: ('1+2 > 4 is ', False)
: ('What is 3 + 2?', 5)

Any hints what may be going wrong?

Dushyant

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

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

* Re: org-babel python eval discrepancy
  2017-08-03 17:31 org-babel python eval discrepancy Dushyant Juneja
@ 2017-08-03 18:22 ` Dov Grobgeld
  2017-08-03 18:54   ` Dushyant Juneja
  2017-08-03 18:31 ` Adam Porter
  1 sibling, 1 reply; 4+ messages in thread
From: Dov Grobgeld @ 2017-08-03 18:22 UTC (permalink / raw)
  To: Dushyant Juneja; +Cc: emacs-orgmode

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

Shell is using python3 and org-mode python2?

On Aug 3, 2017 8:31 PM, "Dushyant Juneja" <juneja.dushyant@gmail.com> wrote:

> Hi,
>
> I have the following code block in my org mode based literate programming
> notes:
>
> #+BEGIN_SRC python
> print('1+2 > 4 is ', 1+2 > 4)
> print("What is 3 + 2?", 3 + 2)
> #+END_SRC
>
> When I tangle it and run the script, it gives me expected output as
> follows:
>
> > python notes.py
> 1+2 > 4 is  False
> What is 3 + 2? 5
>
> However, in buffer evaluation (using =C-c C-c= with cursor on src block)
> gives me the following output, which seems unexpected:
>
> #+BEGIN_SRC python
> print('1+2 > 4 is ', 1+2 > 4)
> print("What is 3 + 2?", 3 + 2)
> #+END_SRC
>
> #+RESULTS:
> : ('1+2 > 4 is ', False)
> : ('What is 3 + 2?', 5)
>
> Any hints what may be going wrong?
>
> Dushyant
>

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

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

* Re: org-babel python eval discrepancy
  2017-08-03 17:31 org-babel python eval discrepancy Dushyant Juneja
  2017-08-03 18:22 ` Dov Grobgeld
@ 2017-08-03 18:31 ` Adam Porter
  1 sibling, 0 replies; 4+ messages in thread
From: Adam Porter @ 2017-08-03 18:31 UTC (permalink / raw)
  To: emacs-orgmode

Lookup "Org babel results" in Google and you should find the right
section of the manual.  You need to set the :results keyword. 

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

* Re: org-babel python eval discrepancy
  2017-08-03 18:22 ` Dov Grobgeld
@ 2017-08-03 18:54   ` Dushyant Juneja
  0 siblings, 0 replies; 4+ messages in thread
From: Dushyant Juneja @ 2017-08-03 18:54 UTC (permalink / raw)
  To: Dov Grobgeld; +Cc: emacs-orgmode

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

Hey Dov,

Bull's eye! Never realized that could hurt.

It so happened that I set the correct python version in my shell before
starting emacs. However, my bashrc file was hardwired to a different
version, which org used every time for evaluating the src blocks.

Thanks for the help!
Dushyant

On Thu, Aug 3, 2017 at 2:22 PM Dov Grobgeld <dov.grobgeld@gmail.com> wrote:

> Shell is using python3 and org-mode python2?
>
> On Aug 3, 2017 8:31 PM, "Dushyant Juneja" <juneja.dushyant@gmail.com>
> wrote:
>
>> Hi,
>>
>> I have the following code block in my org mode based literate programming
>> notes:
>>
>> #+BEGIN_SRC python
>> print('1+2 > 4 is ', 1+2 > 4)
>> print("What is 3 + 2?", 3 + 2)
>> #+END_SRC
>>
>> When I tangle it and run the script, it gives me expected output as
>> follows:
>>
>> > python notes.py
>> 1+2 > 4 is  False
>> What is 3 + 2? 5
>>
>> However, in buffer evaluation (using =C-c C-c= with cursor on src block)
>> gives me the following output, which seems unexpected:
>>
>> #+BEGIN_SRC python
>> print('1+2 > 4 is ', 1+2 > 4)
>> print("What is 3 + 2?", 3 + 2)
>> #+END_SRC
>>
>> #+RESULTS:
>> : ('1+2 > 4 is ', False)
>> : ('What is 3 + 2?', 5)
>>
>> Any hints what may be going wrong?
>>
>> Dushyant
>>
>

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

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

end of thread, other threads:[~2017-08-03 18:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-03 17:31 org-babel python eval discrepancy Dushyant Juneja
2017-08-03 18:22 ` Dov Grobgeld
2017-08-03 18:54   ` Dushyant Juneja
2017-08-03 18:31 ` Adam Porter

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