I hoped to enable a virtualenv with org-babel source block before executing some python.
I wanted to do something like pyenv pyvenv-workon before it evaulates my code block. I didn't want to have to manually enable the virtualenv.
Something like,
#+NAME: elasticsearch_dsl_test
#+BEGIN_SRC: python :prologue "(pyvenv-workon 'elasticsearch)"
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search, Q
client = Elasticsearch()
search = Search(using=client, index="localdev-news-newsentry")
response = search.execute()
print ["No response", "Was successfull"][int(response.success())]
print "Response took {0}ms.".format(response.took)
#+END_SRC
I couldn't quite get it working.
:prologue
will prepend the text as is to the src block. Unquote your prologue and make sure it doesn't return anything that would be prepended. – mutbuerger Jun 29 '16 at 5:07pyvenv-workon
returns will be appended to the src block. Default value of:prologue
is "", so to make sure nothing gets appended you may use:prologue (progn (pyvenv-workon 'elasticsearch) "")
. – mutbuerger Jun 30 '16 at 5:30