emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Loris Bennett <loris.bennett@fu-berlin.de>
Cc: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: Changing the environment before calling source block?
Date: Sun, 03 Oct 2021 14:55:06 +0800	[thread overview]
Message-ID: <87k0iu7g39.fsf@localhost> (raw)
In-Reply-To: <87ft0wea3q.fsf@hornfels.zedat.fu-berlin.de>

"Loris Bennett" <loris.bennett@fu-berlin.de> writes:

> Hi,
>
> I have multiple versions of each of various languages such as Python
> or R.  On the command line I can select a version using the 'module'[1]
> mechanism provided by Lmod[2]:
>
> My question is: How do I change the environment, ideally call 'module
> load ...' but potentially just set environment variables, before calling
> a source block?

It depends on source block language.  For Python, there is :python
header arg where you can specify python command to be used.  I am not
sure about R

More generally, you can advice org-babel-execute-src-block and wrap it
into something like with-environment-variables macro (available in
newest Emacs).

Or you can write a bash source block, set envitonment there as usual,
and invoke your Python/R script using noweb.

Hope it helps.

Best,
Ihor


      reply	other threads:[~2021-10-03  6:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 14:59 Changing the environment before calling source block? Loris Bennett
2021-10-03  6:55 ` Ihor Radchenko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k0iu7g39.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=loris.bennett@fu-berlin.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).