The version of nextflow is N E X T F L O W ~ version 23.10.1 However, according to the official website command:
nextflow Copy code process foo { conda '/path/to/an/existing/env/directory'
''' your_command --here ''' } I correctly set the conda environment path in my process, but it did not activate successfully because my command: python -c "import sys; print(sys.version)" did not display the correct version.
However, if I directly set in the script:
bash Copy code source /path/to/anaconda3/etc/profile.d/conda.sh conda activate ${params.condaEnv1} # This variable value is my environment path it succeeded. Why is this?
I'm assuming you built a docker container to use with nextflow, but it's not clear.
conda activatein the.bashrcare intended for interactive shells, which is not how nextflow interacts with them. There are a few tricks in previous posts on here, but the one I like is to add the conda env toPATH.From my nlrexpress dockerfile:
You can also use a python shebang that points to the conda version of python in some use cases and use the python script as an executable, but I think this is less flexible.
You can then test if it works by invoking something like this:
Which should return the conda installed python. NB, running
docker run -itwill create an interactive shell and invoke the.bashrcfile.