I have a Quarto project with 2 .qmd files, each of them located in a folder with an _environment.local file. Like this:
Notebook_01/
Notebook_01.qmd
environment.local
Notebook_02/
Notebook_02.qmd
environment.local
The _environment.local file in each of the folders has only one line, that indicates the python to be used by reticulate. Each of then points to a different conda environment:
RETICULATE_PYTHON="/Users/user/miniconda3/envs/BionfTools/bin/python" (In folder Notebook_01) RETICULATE_PYTHON="/Users/user/miniconda3/envs/PPanGGOLiN/bin/python" (In folder Notebook_02)
This is because in Notebook_01 I want to use tools installed in the BionfTools conda environment and in Notebook_02 I want to use tools installed in the PPanGGOLiN conda environment.
If I do quarto render RETICULATE_PYTHON gets set for the first rendered file and the same python is used for the second file. The same if I render individual files, whatever I use first for that session gets used all the time.
The only thing that worked for me is doing this on the terminal:
cd Notebook_01
RETICULATE_PYTHON="/Users/isabelfe/miniconda3/envs/BionfTools/bin/python"
quarto render
cd ..
cd Notebook_02
RETICULATE_PYTHON="/Users/isabelfe/miniconda3/envs/PPanGGOLiN/bin/python"
quarto render
cd ..
Is there any way to incorporate something like this in the _quarto.yml to indicate a RETICULATE_PYTHON for each .qmd file? Or for each folder if you locate them in different folders?
This will solve the issue of rendering. But, ideally I will like to be able to just run individual chunks of {bash} code while I am developing on R studio so I can alternate between conda environments easily. I tried using use_miniconda() without luck. Also installing environments in each of the folders directly.
Is summary, is there a way to work in R Studio that allows you to move in between conda environments?
I am not sure that the _environment.local file is meant to be put inside each folder of a quarto project. This would probably work if each of your folder is an independent quarto project.
As you are using reticulate, I suppose you are trying to configure the python version used by python engine inside your .qmd document using R. You could do that at the document level inside a (setup) chunk. See R Markdown Python Engine • reticulate
That would probably the easiest way for you to manage different python version per document.
I tried what you suggest using reticulate. It works in the sense of running python chunks of code. But what I want is to use tools that are installed via Conda in specific environments, so I run then in bash chunks of code like:
```{bash}
#ppanggolin -h
My solution with the _environment.local files in each folder works if I render via terminal. What I am talking about is a more dynamic way to work in RStudio. I use markdown files (and now quarto files) as notebooks as I am developing bioinformatic pipelines that have tools in different Conda environments and I get forced to run the code directly on the terminal, instead of doing it from the notebook chunks of code as I write the code (conda activate does not work on the bash chances of code)