在Snakemake规则中使用conda env中的python模块时出现问题

2024-09-29 17:20:12 发布

您现在位置:Python中文网/ 问答频道 /正文

在我在Snakemake规则中运行的python脚本中,我试图使用python包pysam,它安装在我的一个conda环境中。它也列在我从conda env生成的yaml文件中

我在Snakemake规则中指定conda env的yaml,然后运行一个使用pysam的python脚本,但是我得到一个ModuleNotFoundError: No module named ‘pysam’。在不使用Snakemake的情况下,当我在conda环境中运行脚本时,它可以正常工作

在我的蛇形档案中:

rule match:
    input: "input.bam"
    output: "output.tsv"
    conda: "/path/to/condaenv.yml"   
    script: "scripts/match.py"  

我正在运行它: snakemake --profile lsf --use-conda

这就是错误:

Activating conda environment: /path/to/.snakemake/conda/3824034a93030
Traceback (most recent call last):
  File "/path/to/scripts/tmppa0ynjrn.match.py", line 10, in <module>
    import pysam
ModuleNotFoundError: No module named 'pysam'

编辑:这是我的yaml--

name: chisel
channels:
  - bioconda
  - r
  - conda-forge
  - defaults
dependencies:
  - _libgcc_mutex=0.1=conda_forge
  - _openmp_mutex=4.5=1_gnu
  - backports=1.0=py_2
  - backports.functools_lru_cache=1.6.1=py_0
  - backports_abc=0.5=py_1
  - bcftools=1.12=h45bccc9_1
  - bwa=0.7.17=h5bf99c6_8
  - bzip2=1.0.8=h7f98852_4
  - c-ares=1.17.1=h7f98852_1
  - ca-certificates=2021.5.30=ha878542_0
  - certifi=2019.11.28=py27h8c360ce_1
  - chisel=1.0.0=pyhdfd78af_0
  - cycler=0.10.0=py_2
  - freetype=2.10.4=h0708190_1
  - functools32=3.2.3.2=py_3
  - futures=3.3.0=py27h8c360ce_1
  - gawk=5.1.0=h7f98852_0
  - gsl=2.6=he838d99_2
  - htslib=1.12=h9093b5e_1
  - icu=64.2=he1b5a44_1
  - kiwisolver=1.1.0=py27h9e3301b_1
  - krb5=1.19.1=hcc1bbae_0
  - ld_impl_linux-64=2.35.1=hea4e1c9_2
  - libblas=3.9.0=8_openblas
  - libcblas=3.9.0=8_openblas
  - libcurl=7.77.0=h2574ce0_0
  - libdeflate=1.7=h7f98852_5
  - libedit=3.1.20191231=he28a2e2_2
  - libev=4.33=h516909a_1
  - libffi=3.2.1=he1b5a44_1007
  - libgcc-ng=9.3.0=h2828fa1_19
  - libgfortran-ng=7.5.0=h14aa051_19
  - libgfortran4=7.5.0=h14aa051_19
  - libgomp=9.3.0=h2828fa1_19
  - liblapack=3.9.0=8_openblas
  - libnghttp2=1.43.0=h812cca2_0
  - libopenblas=0.3.12=pthreads_hb3c22a3_1
  - libpng=1.6.37=h21135ba_2
  - libssh2=1.9.0=ha56f1ee_6
  - libstdcxx-ng=9.3.0=h6de172a_19
  - matplotlib-base=2.2.5=py27h250f245_1
  - ncurses=6.2=h58526e2_4
  - numpy=1.16.5=py27h95a1406_0
  - openssl=1.1.1k=h7f98852_0
  - pandas=0.24.2=py27hb3f55d8_0
  - patsy=0.5.1=py_0
  - perl=5.32.1=0_h7f98852_perl5
  - pip=20.1.1=pyh9f0ad1d_0
  - pyparsing=2.4.7=pyh9f0ad1d_0
  - pysam=0.16.0.1=py27hc729bab_3
  - python=2.7.15=h5a48372_1011_cpython
  - python-dateutil=2.8.1=py_0
  - python_abi=2.7=1_cp27mu
  - pytz=2020.1=pyh9f0ad1d_0
  - readline=8.1=h46c0cb4_0
  - samtools=1.12=h9aed4be_1
  - scipy=1.2.1=py27h921218d_2
  - seaborn=0.9.0=py_2
  - setuptools=44.0.0=py27_0
  - singledispatch=3.6.1=pyh44b312d_0
  - six=1.16.0=pyh6c4a22f_0
  - sqlite=3.35.5=h74cdb3f_0
  - statsmodels=0.10.2=py27hc1659b7_0
  - subprocess32=3.5.4=py27h516909a_0
  - tk=8.6.10=h21135ba_1
  - tornado=5.1.1=py27h14c3975_1000
  - wheel=0.36.2=pyhd3deb0d_0
  - xz=5.2.5=h516909a_1
  - zlib=1.2.11=h516909a_1010
prefix: /home/leventhe/miniconda3/envs/chisel

为了能够在python脚本中使用conda env中的模块,我还需要在Snakemake中执行其他操作吗


Tags: topathpyenv脚本yamlmatchconda

热门问题