As in the title, If I have an org file with a python source block of the form
#+BEGIN_SRC python :results none :session py-sess :exports none import numpy as np import matplotlib.pyplot as plt print("Foo") #+END_SRC
C-c C-e l o produces a
:exports none header.
:eval never-export does not help solve this.
The only way I can get around this is if I have a section heading with
:noexport as the tag, but this is not what I want to do in my document structure, as I want to have an org file with python code blocks producing plots which I export to the
As well as this, exporting this block via LaTeX to
#+BEGIN_SRC python :results file :session py-sess :exports results ... filename="foo.png" plt.save(filename) #+END_SRC #+RESULTS: file:foo.png
produces both the figure and the code block.
How can I stop the code blocks from being exported? Is there some hidden setting I'm missing in
Found the problem -- had another package (
ob-sagemath) which had the line
(setq org-export-babel-evaluate nil) in its
use-package config. It seems that that variable should be set as t. I guess I could have found it sooner, but at the same time having that variable be t is a little counter-intuitive in preventing code from being exported.
Also, it took a while to figure this out as there was some weird issue in that a Python source block which printed out help(plt.savefig) caused the export process to crash (the python shell/session just got stuck), but only when running emacs in daemon/client mode and worked fine in "standalone mode". Removed that block and everything worked fine.