Create a virtual environment to specify Python and R

Many applications require specific versions of R and Python or a combination of additional modules. As there might be conflicts between those modules, we recommend to use virtual environments to manage and use those packages.  

 

Individual steps

Log in to ERISOne:

 

#$ssh erisone

 

then load the anaconda module:

$module load anaconda

 

then you can create the conda environment:

$conda create --name env_name 

 

you can already add requirements here like:

 

$conda create --name env_name python=3.7 R=3.6

execution will take a while. Note that you do not need to specify a version. Do not specify it when you do not use R or Python. 

 

To activate the enviorment you type:

 

$conda activate env_name

 

If you have never used conda, it will give you an error:

 

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.

If your shell is Bash or a Bourne variant, enable conda for the current user with

$ echo ". /apps/software-2.12/Anaconda3/5.2.0/etc/profile.d/conda.sh" >> ~/.bashrc

 

 

Do as the error message suggests:

 

$ echo ". /apps/software-2.12/Anaconda3/5.2.0/etc/profile.d/conda.sh" >> ~/.bashrc

 

 

 

 It will add conda to your path so you can activate the environment. for the changes to be active you need to log out and log in again:


  $source ~/.bashrc


After this or a log in you can do:

$conda activate env_name

 

in this virtual environment you can then install packages with conda install package_name (e.g.) :

 

$conda install package 

 

Note that you need to add:

and 

conda activate env_name

To your lsf scripts. 

 

Links

Please read more about conda environments : 

 

https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html

http://know.continuum.io/rs/387-XNW-688/images/conda-cheatsheet.pdf

 


Related articles