Conda 4.10.3 和 Snakemake >5 “__conda_exe” 问题

Conda 4.10.3 and Snakemake >5 "__conda_exe" problem

我有以下问题,当我使用下面的命令时,snakemake 似乎无法解决使用 --use-conda 选项创建环境的问题。

如果我不使用 snakemake 的这个选项并在由 conda 而不是 snakemake 创建的适当环境中启动 snakefile,则命令执行正常。

有人遇到同样的问题吗?

谢谢,

命令:

snakemake -p -d ./ -s 00_Quality_Check.smk -j 4 --use-conda

版本:

错误信息:

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

版本:

错误信息:

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.

您的 conda 环境似乎已损坏,或者您在未安装 conda 的环境中 运行ning snakemake。

查看错误信息的最后一行:

subprocess.CalledProcessError: Command 'conda info --json' returned non-zero exit status 127.

这是说 snakemake 运行 命令 conda info --json 并返回错误代码。在许多系统上,代码 127 表示找不到命令 conda 在这种情况下。调试问题的下一步是 运行 手动执行该命令:

$ conda info --json

$ conda info

如果我是对的,你会收到 command not found 消息。尝试重新安装 conda。

这可能与这个长期打开的 conda 问题有关:

https://github.com/conda/conda/issues/7980

基本上,默认情况下,您无法从脚本中 运行 conda。

为了解决这个问题,以前,人们一直在他们的 ~/.bashrc 或 ~/.bash_profile conda 节之后(即在“# <<< 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

但最近 conda 中似乎发生了一些变化。以下内容现在可能就足够了:

# Make these functions available to scripts.
export -f conda
export -f __conda_activate
export -f __conda_reactivate
export -f __conda_exe

如果这些都不起作用,只需使用大锤:

# 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

执行上述操作有助于修复上面为一位同事报告的相同错误。

重要提示:您需要注销并重新登录才能正常工作。

要进行测试,请将“conda info --json”放入脚本中,然后 运行 该脚本。如果您看到一堵 JSON 的墙,您就解决了问题。