Linux下Snakemake运行报错:module 'asyncio' has no attribute 'coroutine'
Snakemake执行报错:AttributeError: module 'asyncio' has no attribute 'coroutine'
问题详情
在Linux机器上通过以下步骤安装Snakemake:
conda activate base mamba create -c conda-forge -c bioconda -n snakemake snakemake conda activate snakemake
安装无异常,但执行命令snakemake -s Snakemake_job -j n时出现报错:
Building DAG of jobs... Traceback (most recent call last): File "/home/debian/.conda/envs/snakemake/lib/python3.11/site-packages/snakemake/__init__.py", line 747, in snakemake success = workflow.execute( ^^^^^^^^^^^^^^^^^ File "/home/debian/.conda/envs/snakemake/lib/python3.11/site-packages/snakemake/workflow.py", line 949, in execute self.scheduler = JobScheduler( ^^^^^^^^^^^^^ File "/home/debian/.conda/envs/snakemake/lib/python3.11/site-packages/snakemake/scheduler.py", line 109, in __init__ from ratelimiter import RateLimiter File "/home/debian/.conda/envs/snakemake/lib/python3.11/site-packages/ratelimiter.py", line 36, in <module> class RateLimiter(object): File "/home/debian/.conda/envs/snakemake/lib/python3.11/site-packages/ratelimiter.py", line 127, in RateLimiter __aexit__ = asyncio.coroutine(__exit__) ^^^^^^^^^^^^^^^^^ AttributeError: module 'asyncio' has no attribute 'coroutine'
已尝试重装Snakemake、pip安装asyncio,均未解决。
错误原因
Python 3.10+版本中移除了asyncio.coroutine API,但当前环境中安装的ratelimiter版本过旧,仍在调用该废弃接口,导致兼容性报错。
解决方案
方案1:重建兼容的Snakemake环境
直接创建包含适配Python3.11依赖的Snakemake环境:
- 删除现有环境:
conda remove -n snakemake --all
- 创建新环境,指定兼容版本的Snakemake:
conda activate base mamba create -c conda-forge -c bioconda -n snakemake snakemake>=7.32.4 python=3.11 conda activate snakemake
方案2:更新现有环境中的ratelimiter
无需重建环境,直接升级ratelimiter到适配Python3.10+的版本:
conda activate snakemake pip install --upgrade ratelimiter>=1.2.0.post0
验证
执行以下命令确认版本正常:
snakemake --version
之后重新运行你的任务:
snakemake -s Snakemake_job -j n
内容的提问来源于stack exchange,提问作者chippycentra
相关产品推荐
相关产品推荐

