You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Snakemake fastqc wrapper突然失效,Python版本冲突及模块缺失如何解决?

问题描述

现有Snakemake的FastQC wrapper规则如下:

rule fastqc:
    input:
        "reads/{sample}_trimmed.fq.gz"
    output:
        html="qc/fastqc/{sample}.html",
        zip="qc/fastqc/{sample}_fastqc.zip" # the suffix _fastqc.zip is necessary for multiqc to find the file
    params:
        extra = "--quiet"
    log:
        "logs/fastqc/{sample}.log"
    threads: config["resources"]["fastqc"]["cpu"]
    conda:
        "envs/qc.yaml"
    wrapper:
        "v1.31.1/bio/fastqc"

对应的envs/qc.yaml环境配置:

name: qc
channels: 
  - bioconda
dependencies:
  - python
  - fastqc
  - multiqc

原本正常运行的规则突然失效,核心报错为:

Environment defines Python version < 3.7. Using Python of the main process to execute script. Note that this cannot be avoided, because the script uses data structures from Snakemake which are Python >=3.7 only.

ModuleNotFoundError: No module named 'snakemake_wrapper_utils'

解决方案

1. 锁定Python版本并补充依赖

修改envs/qc.yaml,指定Python版本不低于3.7,同时添加缺失的snakemake-wrapper-utils依赖:

name: qc
channels: 
  - bioconda
dependencies:
  - python>=3.7
  - fastqc
  - multiqc
  - snakemake-wrapper-utils

2. 重建conda环境

删除Snakemake自动生成的旧环境缓存,强制重新构建符合版本要求的环境:

# 删除指定的旧缓存环境(替换为报错中显示的环境ID)
rm -rf .snakemake/conda/32ae7e363cfd65f035e232e794d5bc2b_

# 重新运行Snakemake,自动构建新环境
snakemake --use-conda [你的其他运行参数]

3. (可选)改用原生FastQC命令替代wrapper

如果不想调整Python版本,也可以放弃wrapper,直接用原生shell命令实现规则功能:

rule fastqc:
    input:
        "reads/{sample}_trimmed.fq.gz"
    output:
        html="qc/fastqc/{sample}.html",
        zip="qc/fastqc/{sample}_fastqc.zip"
    params:
        extra = "--quiet"
    log:
        "logs/fastqc/{sample}.log"
    threads: config["resources"]["fastqc"]["cpu"]
    conda:
        "envs/qc.yaml"
    shell:
        "fastqc {params.extra} -t {threads} -o qc/fastqc/ {input}"

内容的提问来源于stack exchange,提问作者justinian482

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 23:09:54