I have the following problem, when I used the command below, it appears that snakemake cannot resolve the creation of the environment using the --use-conda option.
If I not use this option of snakemake and launch the snakefile in an appropriate environment created by conda and not by snakemake, the command execution is ok.
Did someone have the same problem ?
Thanks,
Command:
snakemake -p -d ./ -s 00_Quality_Check.smk -j 4 --use-conda
Versions:
Error message:
Building DAG of jobs...
CreateCondaEnvironmentException:
Unable to check conda version:
environment: ligne 10: __conda_exe : commande introuvable
File "/home/usr/miniconda3/envs/snake/lib/python3.9/site-packages/snakemake/deployment/conda.py", line 232, in create
File "/home/usr/miniconda3/envs/snake/lib/python3.9/site-packages/snakemake/deployment/conda.py", line 343, in __new__
File "/home/usr/miniconda3/envs/snake/lib/python3.9/site-packages/snakemake/deployment/conda.py", line 356, in __init__
File "/home/usr/miniconda3/envs/snake/lib/python3.9/site-packages/snakemake/deployment/conda.py", line 410, in _check
Version:
Error message:
Building DAG of jobs...
environment: ligne 10: __conda_exe : commande introuvable
Traceback (most recent call last):
File "/home/usr/miniconda3/envs/snake/lib/python3.9/site-packages/snakemake/__init__.py", line 699, in snakemake
success = workflow.execute(
File "/home/usr/miniconda3/envs/snake/lib/python3.9/site-packages/snakemake/workflow.py", line 933, in execute
dag.create_conda_envs(
File "/home/usr/miniconda3/envs/snake/lib/python3.9/site-packages/snakemake/dag.py", line 304, in create_conda_envs
env.create(dryrun)
File "/home/usr/miniconda3/envs/snake/lib/python3.9/site-packages/snakemake/deployment/conda.py", line 281, in create
conda = Conda(self._container_img)
File "/home/usr/miniconda3/envs/snake/lib/python3.9/site-packages/snakemake/deployment/conda.py", line 433, in __init__
shell.check_output(self._get_cmd("conda info --json"))
File "/home/usr/miniconda3/envs/snake/lib/python3.9/site-packages/snakemake/shell.py", line 63, in check_output
return sp.check_output(cmd, shell=True, executable=executable, **kwargs)
File "/home/usr/miniconda3/envs/snake/lib/python3.9/subprocess.py", line 424, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/home/usr/miniconda3/envs/snake/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'conda info --json' returned non-zero exit status 127.
This may be related to this long open conda issue:
https://github.com/conda/conda/issues/7980
Basically, you can't run conda from within scripts by default.
To address this, previously, people had been putting something like the following in their ~/.bashrc or ~/.bash_profile after the conda stanzas (i.e., after the "# <<< conda initialize <<<"):
# Make these functions available to scripts.
export -f conda
export -f __conda_activate
export -f __add_sys_prefix_to_path
export -f __conda_hashr
But it looks like something in conda changed recently. The following may now be sufficient:
# Make these functions available to scripts.
export -f conda
export -f __conda_activate
export -f __conda_reactivate
export -f __conda_exe
If neither of those work, just use a sledgehammer:
# Make these functions available to scripts.
export -f conda
export -f __conda_activate
export -f __conda_reactivate
export -f __add_sys_prefix_to_path
export -f __conda_hashr
export -f __conda_exe
Doing the above helped fix the same error reported above for a colleague.
Important: You'll need to log out and log back in for it to work.
To test, put "conda info --json" into a script, and run that script. If you see a wall of JSON, you've fixed the problem.