* Changing the environment before calling source block?
@ 2021-03-15 14:59 Loris Bennett
2021-10-03 6:55 ` Ihor Radchenko
0 siblings, 1 reply; 2+ messages in thread
From: Loris Bennett @ 2021-03-15 14:59 UTC (permalink / raw)
To: Org Mode Mailing List
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]:
module load Python/2.7.18-GCCcore-9.3.0
or
module load Python/3.8.6-GCCcore-10.2.0
This 'module' mechanism basically just provides a sane way to tweak and
untweak environment variables.
My question is: How do I change the environment, ideally call 'module
load ...' but potentially just set environment variables, before calling
a source block?
Cheers,
Loris
Footnotes:
[1] Nothing to do with Python modules
[2] https://lmod.readthedocs.io/en/latest/index.html
--
This signature is currently under construction.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Changing the environment before calling source block?
2021-03-15 14:59 Changing the environment before calling source block? Loris Bennett
@ 2021-10-03 6:55 ` Ihor Radchenko
0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2021-10-03 6:55 UTC (permalink / raw)
To: Loris Bennett; +Cc: Org Mode Mailing List
"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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-03 6:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-15 14:59 Changing the environment before calling source block? Loris Bennett
2021-10-03 6:55 ` Ihor Radchenko
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).