0

So, I guess this is done in a really simple way, but I do not have experience with it, so I do not understand what is the issue. Let's say I have a conda environment example_env and a Singularity image example.simg.

I can run the image: singularity run --nv /mnt/appl/singularity_images/pytorch-19.03-py3.simg

Once I am in the Singularity container, I can write conda activate example_env, and it works for me without any problem.

Now, I want to switch from the interactive section to a script. So, instead of using singularity run and entering the interactive shell, I have tried singularity exec: singularity exec example.simg bash scripts/train.sh, where train.sh contains only one (just for now, of course) command: conda activate example_env.

However, now it does not work, and gives me the following error: CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. To initialize your shell, run $ conda init <SHELL_NAME> If I try to follow the error message, and add the conda init command, it does not help.

What is wrong, and how can I run conda activate with singularity exec?

Valeria
  • 1,508
  • 4
  • 20
  • 44

1 Answers1

0

I don't think you run the echo commands as shown in this stackoverflow. I think you should check out the following.

Activate conda environment on execution of Singularity container in Nextflow

SarthakJain
  • 1,226
  • 6
  • 11
  • 2
    To be honest, I do not really understand how to use that answer in my situation, but adding a line from https://github.com/conda/conda/issues/7980 solved my issue. (`source ~/anaconda3/etc/profile.d/conda.sh`) – Valeria Jul 15 '21 at 23:03