Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run "conda ***" in a system command in R

Tags:

bash

r

conda

I want to run a system command in a conda environment, but I can't figure out how to get R to send the command to a properly initialized bash shell. I tried system('conda activate myenv && mycommand'), but I get a warning about needing to run conda init bash. Trying system('conda init bash && conda activate myenv') throws the same error. Making bash the first command freezes RStudio, e.g. system('bash && ....)`.

Is there any way to send a system command in R that would run AFTER sourcing my .bashrc file?

like image 455
abalter Avatar asked Nov 06 '19 13:11

abalter


People also ask

How do I run a Conda in bash?

for anaconda 4 : bashrc and then copy the path into the file and save it after that you activate the changes using source . bashrc. When I type export PATH=~/anaconda3/bin:$PATH into the terminal and then run conda --version it works fine.

Why after installing Anaconda conda not found?

If you face the 'conda command not found' error, the first and most common solution is to ensure you have conda installed. You can install conda using either the anaconda or miniconda packages. In this tutorial, we will use the anaconda installer.


1 Answers

Use Conda Run.

system('conda run -n myenv mycommand')

See conda run --help for details.

like image 87
merv Avatar answered Oct 25 '22 05:10

merv