w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Emacs Org Mode: Executing simple python code

There are two ways of getting the result of a source block - output and value. You mixed them up, hence the troubles.

First block is fine.

To fix the second block:

#+begin_src python :results value
return 1+1

To fix the third block:

#+begin_src python :results output
print 1+1

When output mode is value you must return. Just putting it there like you did with 1+1 won't do. In the third one you want the result to be printed output, but your default session setting is value(mine defaults to output btw).

And this bit about org-confirm-babel-evaluate is kind of irrelevant to the question. I just have it set to nil.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.