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

Snakemake conda环境中jupyter nbconvert报错求助

问题:jupyter nbconvert执行报错TypeError: entry_points() got an unexpected keyword argument 'group'

环境配置文件(envs/jupyter.yaml)

channels:
  - conda-forge
  - bioconda
  - defaults
dependencies:
  - libgcc-ng=12.2.0
  - libblas=3.9.0
  - liblapack=3.9.0
  - notebook=6.5.2
  - r-base=4.2.1
  - r-tidyverse=1.3.2
  - bioconductor-complexheatmap=2.14.0
  - bioconductor-biostrings=2.66.0
  - r-irkernel=1.3.1
  - jupyter_contrib_nbextensions=0.7.0
  - biopython=1.74
  - scipy=1.10.0

Snakefile规则

rules stat:
    conda: 'envs/jupyter.yaml'
    notebook: rules.notebook.output.stat

完整报错信息

Activating conda environment: .snakemake/conda/dd29012628c49c75d6a5c31f75898e03
Traceback (most recent call last):
  File "/share/home/sibyl/bak/sars2_surveillance/.snakemake/conda/dd29012628c49c75d6a5c31f75898e03/bin/jupyter-nbconvert", line 6, in <module>
    from nbconvert.nbconvertapp import main
  File "/share/home/sibyl/bak/sars2_surveillance/.snakemake/conda/dd29012628c49c75d6a5c31f75898e03/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 185, in <module>
    class NbConvertApp(JupyterApp):
  File "/share/home/sibyl/bak/sars2_surveillance/.snakemake/conda/dd29012628c49c75d6a5c31f75898e03/lib/python3.8/site-packages/nbconvert/nbconvertapp.py", line 278, in NbConvertApp
    formats=get_export_names()
  File "/share/home/sibyl/bak/sars2_surveillance/.snakemake/conda/dd29012628c49c75d6a5c31f75898e03/lib/python3.8/site-packages/nbconvert/exporters/base.py", line 137, in get_export_names
    exporters = sorted(e.name for e in entry_points(group="nbconvert.exporters"))
TypeError: entry_points() got an unexpected keyword argument 'group'

RuleException:
CalledProcessError in file /share/home/sibyl/bak/sars2_surveillance/Snakefile, line 310:
Command 'source /share/home/sibyl/miniconda3/envs/sars2/bin/activate '/share/home/sibyl/bak/sars2_surveillance/.snakemake/conda/dd29012628c49c75d6a5c31f75898e03'; set -euo pipefail;  jupyter-nbconvert --log-level ERROR --execute --output /share/home/sibyl/bak/sars2_surveillance/test/output/0log/upstream_stat/test.r.ipynb --to notebook --ExecutePreprocessor.timeout=-1 /share/home/sibyl/bak/sars2_surveillance/.snakemake/scripts/tmpcnlnf1wn.upstream_stat.r.ipynb' returned non-zero exit status 1.
  File "/share/home/sibyl/bak/sars2_surveillance/Snakefile", line 310, in __rule_upstream_stat
  File "/share/home/sibyl/miniconda3/envs/sars2/lib/python3.11/concurrent/futures/thread.py", line 58, in run

当前环境中的nbconvert版本

- nbconvert=7.2.7=pyhd8ed1ab_0
  - nbconvert-core=7.2.7=pyhd8ed1ab_0
  - nbconvert-pandoc=7.2.7=pyhd8ed1ab_0

解决方法

该错误源于nbconvert 7.x与Python 3.8环境下的importlib_metadata版本不兼容,entry_points(group=...)参数需要特定版本的importlib_metadata支持,可通过以下途径解决:

  1. 添加importlib_metadata版本约束
    在conda环境配置文件中明确指定importlib_metadata>=4.8.0,确保nbconvert能正确调用entry_points方法:
channels:
  - conda-forge
  - bioconda
  - defaults
dependencies:
  - libgcc-ng=12.2.0
  - libblas=3.9.0
  - liblapack=3.9.0
  - notebook=6.5.2
  - r-base=4.2.1
  - r-tidyverse=1.3.2
  - bioconductor-complexheatmap=2.14.0
  - bioconductor-biostrings=2.66.0
  - r-irkernel=1.3.1
  - jupyter_contrib_nbextensions=0.7.0
  - biopython=1.74
  - scipy=1.10.0
  - importlib_metadata>=4.8.0
  1. 重建conda环境
    删除snakemake生成的旧环境,重新运行任务:
rm -rf .snakemake/conda/dd29012628c49c75d6a5c31f75898e03
snakemake --use-conda
  1. 降级nbconvert到兼容版本
    若上述方法无效,可指定nbconvert为Python3.8兼容的稳定版(如6.5.4),在yaml中添加:
- nbconvert=6.5.4

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.05 03:55:13